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

Issue 8224026: Add a PassScopedPtr into base/memory. (Closed)

Created:
9 years, 2 months ago by awong
Modified:
9 years ago
CC:
chromium-reviews, Paweł Hajdan Jr., brettw-cc_chromium.org, willchan no longer on Chromium, akalin
Visibility:
Public.

Description

Add a PassScopedPtr into base/memory. This can be used in conjunction with base::Bind() to pass ownership of data into a bound Callback. The class itself has no thread safety. It requires external synchronization. BUG=96118 TEST=new unittests.

Patch Set 1 #

Patch Set 2 : Add the actual files. #

Patch Set 3 : beef up comment #

Patch Set 4 : fixed small bug #

Patch Set 5 : neutered ptr. #

Patch Set 6 : rebased #

Patch Set 7 : Fix comments. #

Patch Set 8 : Working prototype (uses friends) #

Patch Set 9 : fix style #

Patch Set 10 : Anchroed PassOwnPtr with Bind. #

Total comments: 14

Patch Set 11 : Added unittest that tests the actual basic use case...and found a bug. :-/ #

Patch Set 12 : Fixed it. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+469 lines, -2 lines) Patch
M base/base.gyp View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -0 lines 0 comments Download
M base/base.gypi View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -0 lines 0 comments Download
M base/bind_helpers.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +31 lines, -0 lines 0 comments Download
M base/bind_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 4 chunks +59 lines, -2 lines 0 comments Download
M base/callback_internal.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +8 lines, -0 lines 0 comments Download
A base/memory/pass_scoped_ptr.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +211 lines, -0 lines 0 comments Download
A base/memory/pass_scoped_ptr_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +158 lines, -0 lines 0 comments Download

Messages

Total messages: 20 (0 generated)
awong
Darin, I think you might be best for this review since it's a potentially much ...
9 years, 2 months ago (2011-10-11 02:51:20 UTC) #1
darin (slow to review)
There are some gotchas with WebKit's PassOwnPtr that may be worth reviewing. Dave Levin may ...
9 years, 2 months ago (2011-10-11 05:01:10 UTC) #2
willchan no longer on Chromium
Darin, have you kept up to date with the other threads wrt base::Owned() and everything? ...
9 years, 2 months ago (2011-10-11 05:09:52 UTC) #3
darin (slow to review)
Hmm... base::Owned() makes a lot of sense, although I might consider naming it Retained() instead. ...
9 years, 2 months ago (2011-10-11 05:41:19 UTC) #4
willchan no longer on Chromium
On Mon, Oct 10, 2011 at 10:41 PM, Darin Fisher <darin@chromium.org> wrote: > Hmm... > ...
9 years, 2 months ago (2011-10-11 05:52:42 UTC) #5
awong
On Oct 10, 2011 10:52 PM, "William Chan (陈智昌)" <willchan@chromium.org> wrote: > > On Mon, ...
9 years, 2 months ago (2011-10-11 06:34:46 UTC) #6
levin
On 2011/10/11 05:01:10, darin wrote: > There are some gotchas with WebKit's PassOwnPtr that may ...
9 years, 2 months ago (2011-10-11 22:21:08 UTC) #7
darin (slow to review)
I prefer pass_scoped_ptr too. -Darin On Tue, Oct 11, 2011 at 3:21 PM, <levin@chromium.org> wrote: ...
9 years, 2 months ago (2011-10-11 22:53:03 UTC) #8
willchan no longer on Chromium
pass_scoped_ptr == MaybeCapturePtr, right? I'm fine with that, although I'd want to change the name. ...
9 years, 2 months ago (2011-10-12 00:41:42 UTC) #9
awong
Dave and I white boarded a bit today on passownptr. I think a lot of ...
9 years, 2 months ago (2011-10-12 03:05:07 UTC) #10
darin (slow to review)
Right... OK On Tue, Oct 11, 2011 at 10:01 PM, William Chan (陈智昌) <willchan@chromium.org>wrote: > ...
9 years, 2 months ago (2011-10-12 05:04:33 UTC) #11
awong
Okay...I have been defeated by the C++ type system. I think the best we can ...
9 years, 2 months ago (2011-10-12 22:35:36 UTC) #12
awong
PTAL. The summary of what Dave and I were attempting, but ultimately failed at doing ...
9 years, 2 months ago (2011-10-12 23:47:03 UTC) #13
awong
Actually, hold off. I'm apparently about to eat crow. Somehow this is now working... -Albert ...
9 years, 2 months ago (2011-10-13 00:42:03 UTC) #14
awong
Well what do ya know...I actually got it working. There are 2 questions at the ...
9 years, 2 months ago (2011-10-13 07:57:51 UTC) #15
awong
Reviving this now that I'm back from vacation. Suggested reading order: pass_own_ptr.h, followed by unittests.
9 years, 1 month ago (2011-11-01 20:40:17 UTC) #16
levin
Just a few comments and nothing major. http://codereview.chromium.org/8224026/diff/24014/base/bind_unittest.cc File base/bind_unittest.cc (right): http://codereview.chromium.org/8224026/diff/24014/base/bind_unittest.cc#newcode660 base/bind_unittest.cc:660: EXPECT_EQ(0, deletes); ...
9 years, 1 month ago (2011-11-02 00:51:30 UTC) #17
awong
Hah. Turns out I didn't actually manage to unittest the most obvious, basic, use case. ...
9 years, 1 month ago (2011-11-11 00:21:58 UTC) #18
awong
aaaand...I think I fixed it. Using move semantic emulation from C++03. The API morphed a ...
9 years, 1 month ago (2011-11-11 16:20:50 UTC) #19
awong
9 years ago (2011-12-06 00:03:55 UTC) #20
This has been superseded by:
  http://codereview.chromium.org/8774032/

Closing this CL.


On 2011/11/11 16:20:50, awong wrote:
> aaaand...I think I fixed it.  Using move semantic emulation from C++03.
> 
> The API morphed a little, but I think it is cleaner.
> 
> Functions can now return a PassOwnPtr<T>.  However, when using Bind(), you
have
> to call ptr.PassForBind() instead of ptr.Pass().

Powered by Google App Engine
This is Rietveld 408576698