Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(794)

Unified Diff: webrtc/base/testclient.h

Issue 2859373003: Refactor TestClient to use std::unique_ptr, and fix VirtualSocketServerTest leaks. (Closed)
Patch Set: git cl format Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/base/socket_unittest.cc ('k') | webrtc/base/testclient.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/testclient.h
diff --git a/webrtc/base/testclient.h b/webrtc/base/testclient.h
index 74ef8cc3762c139a39177a028212121d07f98cc7..a6f8bc5fe99f2a60a5960ef0cc003146ff6d96da 100644
--- a/webrtc/base/testclient.h
+++ b/webrtc/base/testclient.h
@@ -11,6 +11,7 @@
#ifndef WEBRTC_BASE_TESTCLIENT_H_
#define WEBRTC_BASE_TESTCLIENT_H_
+#include <memory>
#include <vector>
#include "webrtc/base/asyncudpsocket.h"
#include "webrtc/base/constructormagic.h"
@@ -42,7 +43,7 @@ class TestClient : public sigslot::has_slots<> {
// Creates a client that will send and receive with the given socket and
// will post itself messages with the given thread.
- explicit TestClient(AsyncPacketSocket* socket);
+ explicit TestClient(std::unique_ptr<AsyncPacketSocket> socket);
~TestClient() override;
SocketAddress address() const { return socket_->GetLocalAddress(); }
@@ -63,9 +64,8 @@ class TestClient : public sigslot::has_slots<> {
int SendTo(const char* buf, size_t size, const SocketAddress& dest);
// Returns the next packet received by the client or 0 if none is received
kwiberg-webrtc 2017/05/05 12:40:31 Hmm. "nullptr" or "null" instead of "0" here...
nisse-webrtc 2017/05/05 12:56:06 Done.
- // within the specified timeout. The caller must delete the packet
- // when done with it.
- Packet* NextPacket(int timeout_ms);
+ // within the specified timeout.
+ std::unique_ptr<Packet> NextPacket(int timeout_ms);
// Checks that the next packet has the given contents. Returns the remote
// address that the packet was sent from.
@@ -95,8 +95,8 @@ class TestClient : public sigslot::has_slots<> {
bool CheckTimestamp(int64_t packet_timestamp);
CriticalSection crit_;
- AsyncPacketSocket* socket_;
- std::vector<Packet*>* packets_;
+ std::unique_ptr<AsyncPacketSocket> socket_;
+ std::vector<std::unique_ptr<Packet>> packets_;
int ready_to_send_count_ = 0;
int64_t prev_packet_timestamp_;
RTC_DISALLOW_COPY_AND_ASSIGN(TestClient);
« no previous file with comments | « webrtc/base/socket_unittest.cc ('k') | webrtc/base/testclient.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698