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

Issue 2859373003: Refactor TestClient to use std::unique_ptr, and fix VirtualSocketServerTest leaks. (Closed)

Created:
3 years, 7 months ago by nisse-webrtc
Modified:
3 years, 7 months ago
CC:
webrtc-reviews_webrtc.org, tterriberry_mozilla.com, kwiberg-webrtc
Target Ref:
refs/heads/master
Project:
webrtc
Visibility:
Public.

Description

Refactor TestClient to use std::unique_ptr, and fix VirtualSocketServerTest leaks. BUG=None Review-Url: https://codereview.webrtc.org/2859373003 Cr-Commit-Position: refs/heads/master@{#18043} Committed: https://chromium.googlesource.com/external/webrtc/+/32f25051853fcf483f0a6f145c278eabcc112fc7

Patch Set 1 #

Total comments: 13

Patch Set 2 : Address comments. And make VirtualSocketServerTest::ss_ a non-pointer. #

Patch Set 3 : git cl format #

Total comments: 2

Patch Set 4 : Comment fix, 0 -> null. #

Total comments: 3

Patch Set 5 : Fix more leaks in VirtualSocketServerTest. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+207 lines, -210 lines) Patch
M webrtc/base/nat_unittest.cc View 1 3 chunks +5 lines, -5 lines 0 comments Download
M webrtc/base/proxy_unittest.cc View 1 chunk +4 lines, -3 lines 0 comments Download
M webrtc/base/socket_unittest.cc View 4 chunks +7 lines, -5 lines 0 comments Download
M webrtc/base/testclient.h View 1 2 3 4 chunks +7 lines, -7 lines 0 comments Download
M webrtc/base/testclient.cc View 1 8 chunks +13 lines, -23 lines 0 comments Download
M webrtc/base/testclient_unittest.cc View 1 3 chunks +6 lines, -5 lines 0 comments Download
M webrtc/base/virtualsocket_unittest.cc View 1 2 3 4 40 chunks +155 lines, -151 lines 0 comments Download
M webrtc/p2p/base/relayserver_unittest.cc View 3 chunks +6 lines, -7 lines 0 comments Download
M webrtc/p2p/base/stunserver_unittest.cc View 3 chunks +4 lines, -4 lines 0 comments Download

Messages

Total messages: 26 (13 generated)
nisse-webrtc
Please take a look. I have no idea why the VirtualSocketServerTests have ever passed the ...
3 years, 7 months ago (2017-05-05 08:56:23 UTC) #2
kwiberg-webrtc
Great initiative! https://codereview.webrtc.org/2859373003/diff/1/webrtc/base/nat_unittest.cc File webrtc/base/nat_unittest.cc (right): https://codereview.webrtc.org/2859373003/diff/1/webrtc/base/nat_unittest.cc#newcode43 webrtc/base/nat_unittest.cc:43: return new TestClient(WrapUnique(new AsyncTCPSocket(socket, false))); Use MakeUnique ...
3 years, 7 months ago (2017-05-05 11:04:42 UTC) #4
nisse-webrtc
https://codereview.webrtc.org/2859373003/diff/1/webrtc/base/nat_unittest.cc File webrtc/base/nat_unittest.cc (right): https://codereview.webrtc.org/2859373003/diff/1/webrtc/base/nat_unittest.cc#newcode43 webrtc/base/nat_unittest.cc:43: return new TestClient(WrapUnique(new AsyncTCPSocket(socket, false))); On 2017/05/05 11:04:42, kwiberg-webrtc ...
3 years, 7 months ago (2017-05-05 12:12:57 UTC) #5
kwiberg-webrtc
lgtm (but see the comment about "0") https://codereview.webrtc.org/2859373003/diff/1/webrtc/base/nat_unittest.cc File webrtc/base/nat_unittest.cc (right): https://codereview.webrtc.org/2859373003/diff/1/webrtc/base/nat_unittest.cc#newcode43 webrtc/base/nat_unittest.cc:43: return new ...
3 years, 7 months ago (2017-05-05 12:40:31 UTC) #6
nisse-webrtc
Thanks for the review. I just remembered that Karl is root owner (I checked only ...
3 years, 7 months ago (2017-05-05 12:56:06 UTC) #7
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/2859373003/60001
3 years, 7 months ago (2017-05-05 12:56:48 UTC) #10
commit-bot: I haz the power
Try jobs failed on following builders: linux_memcheck on master.tryserver.webrtc (JOB_FAILED, http://build.chromium.org/p/tryserver.webrtc/builders/linux_memcheck/builds/7751)
3 years, 7 months ago (2017-05-05 13:25:02 UTC) #12
nisse-webrtc
On 2017/05/05 13:25:02, commit-bot: I haz the power wrote: > Try jobs failed on following ...
3 years, 7 months ago (2017-05-05 14:47:07 UTC) #13
Taylor Brandstetter
So far lgtm https://codereview.webrtc.org/2859373003/diff/60001/webrtc/base/virtualsocket_unittest.cc File webrtc/base/virtualsocket_unittest.cc (right): https://codereview.webrtc.org/2859373003/diff/60001/webrtc/base/virtualsocket_unittest.cc#newcode179 webrtc/base/virtualsocket_unittest.cc:179: AsyncSocket* socket = Would be better ...
3 years, 7 months ago (2017-05-07 21:37:00 UTC) #14
nisse-webrtc
This has now passed a local valgrind run. We'll see if the bots are happy. ...
3 years, 7 months ago (2017-05-08 07:51:15 UTC) #15
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/2859373003/80001
3 years, 7 months ago (2017-05-08 08:55:05 UTC) #22
commit-bot: I haz the power
Committed patchset #5 (id:80001) as https://chromium.googlesource.com/external/webrtc/+/32f25051853fcf483f0a6f145c278eabcc112fc7
3 years, 7 months ago (2017-05-08 08:57:23 UTC) #25
kwiberg-webrtc
3 years, 7 months ago (2017-05-08 10:21:26 UTC) #26
Message was sent while issue was closed.
https://codereview.webrtc.org/2859373003/diff/60001/webrtc/base/virtualsocket...
File webrtc/base/virtualsocket_unittest.cc (right):

https://codereview.webrtc.org/2859373003/diff/60001/webrtc/base/virtualsocket...
webrtc/base/virtualsocket_unittest.cc:179: AsyncSocket* socket =
On 2017/05/08 07:51:15, nisse-webrtc wrote:
> On 2017/05/07 21:37:00, Taylor Brandstetter wrote:
> > Would be better to use MakeUnique here rather than when it's passed into
> > client1, so there's never a raw pointer to deal with.
> 
> I think AsyncUDPSocket takes over ownership, via a raw pointer (changing that
to
> unique_ptr is desirable, but not in this cl).
> 
> So it could be changed to unique_ptr + .release, but I'm not sure that makes
> things clearer.

I would definitely say that using unique_ptr here would make things clearer. As
it is, you have to look at the docs (or the implementation) of
CreateAsyncSocket() and the AsyncUDPSocket constructor to see what's going on
with the ownership; but if you had stored the AsyncSocket in a unique_ptr and
called release() on it at the end, it would be immediately obvious that
CreateAsyncSocket() returns an owning pointer, and that we pass the ownership to
AsyncUDPSocket().

No need to go back and amend this CL, though; I just wanted to provide some
unrequested good advice for the future. :-)

Powered by Google App Engine
This is Rietveld 408576698