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

Unified Diff: webrtc/base/testclient.h

Issue 2859373003: Refactor TestClient to use std::unique_ptr, and fix VirtualSocketServerTest leaks. (Closed)
Patch Set: 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
Index: webrtc/base/testclient.h
diff --git a/webrtc/base/testclient.h b/webrtc/base/testclient.h
index 74ef8cc3762c139a39177a028212121d07f98cc7..eae0bfd8857d3653970cd293f3b275af800f4c4d 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(); }
@@ -65,7 +66,7 @@ class TestClient : public sigslot::has_slots<> {
// Returns the next packet received by the client or 0 if none is received
// within the specified timeout. The caller must delete the packet
// when done with it.
kwiberg-webrtc 2017/05/05 11:04:42 The last sentence of the comment is no longer nece
nisse-webrtc 2017/05/05 12:12:56 Done.
- Packet* NextPacket(int timeout_ms);
+ 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 +96,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);

Powered by Google App Engine
This is Rietveld 408576698