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

Issue 9717021: Make Callback::Reset() return a copy to support use-cases where Run() ends up modifying |*this|. (Closed)

Created:
8 years, 9 months ago by Ami GONE FROM CHROMIUM
Modified:
8 years, 9 months ago
CC:
chromium-reviews, feature-media-reviews_chromium.org, brettw-cc_chromium.org
Visibility:
Public.

Description

Make Callback::Reset() return a copy to support use-cases where Run() ends up modifying |*this|. Callers can use cb.Reset().Run(args...); to avoid reentrancy-like bugs. Replace the special-purpose versions of ResetAndRunCB in the media/ codebase with this more-general facility. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=128772

Patch Set 1 : . #

Total comments: 3

Patch Set 2 : rebased #

Total comments: 4

Patch Set 3 : . #

Patch Set 4 : Reset returns copy of *this #

Patch Set 5 : base::ResetAndReturn is born. #

Total comments: 6

Patch Set 6 : no base:: #

Unified diffs Side-by-side diffs Delta from patch set Stats (+72 lines, -40 lines) Patch
M base/base.gypi View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
A base/callback_helpers.h View 1 2 3 4 1 chunk +30 lines, -0 lines 0 comments Download
M base/callback_unittest.cc View 1 2 3 4 5 3 chunks +25 lines, -10 lines 0 comments Download
M content/renderer/media/capture_video_decoder.cc View 1 2 3 4 2 chunks +2 lines, -1 line 0 comments Download
M media/base/composite_filter.cc View 1 2 3 4 2 chunks +3 lines, -2 lines 0 comments Download
M media/base/composite_filter_unittest.cc View 1 2 3 4 3 chunks +3 lines, -2 lines 0 comments Download
M media/base/filters.h View 1 2 3 4 1 chunk +0 lines, -6 lines 0 comments Download
M media/base/filters.cc View 1 2 3 4 1 chunk +0 lines, -14 lines 0 comments Download
M media/filters/audio_renderer_base.cc View 1 2 3 4 3 chunks +3 lines, -2 lines 0 comments Download
M media/filters/gpu_video_decoder.cc View 1 2 3 4 2 chunks +2 lines, -1 line 0 comments Download
M media/filters/video_renderer_base.cc View 1 2 3 4 3 chunks +3 lines, -2 lines 0 comments Download

Messages

Total messages: 18 (0 generated)
Ami GONE FROM CHROMIUM
Fred/Will: the idiom of ResetAndRun has been important in the media codebase where we frequently ...
8 years, 9 months ago (2012-03-17 05:05:12 UTC) #1
akalin
I think this could come in handy in other places in the code, but I'm ...
8 years, 9 months ago (2012-03-19 21:53:20 UTC) #2
Ami GONE FROM CHROMIUM
On Mon, Mar 19, 2012 at 10:53 PM, <akalin@chromium.org> wrote: > I think this could ...
8 years, 9 months ago (2012-03-20 13:02:41 UTC) #3
willchan no longer on Chromium
I'm hesitant due to having to add the method to each of the Callback classes. ...
8 years, 9 months ago (2012-03-20 17:06:45 UTC) #4
willchan no longer on Chromium
Oh, and I'd rather expose Reset() to Callback than have a ResetAndRun() in Callback. On ...
8 years, 9 months ago (2012-03-20 17:39:24 UTC) #5
Ami GONE FROM CHROMIUM
> > Oh, and I'd rather expose Reset() to Callback than have a ResetAndRun() in ...
8 years, 9 months ago (2012-03-20 19:40:12 UTC) #6
akalin
> If I'm following you then I think that'd require another pump file, which > ...
8 years, 9 months ago (2012-03-21 00:51:52 UTC) #7
Jeffrey Yasskin (google)
On 2012/03/21 00:51:52, akalin wrote: > > If I'm following you then I think that'd ...
8 years, 9 months ago (2012-03-21 02:21:07 UTC) #8
Ami GONE FROM CHROMIUM
> > So you can do: > base::Move(foo_cb).Run(bar, baz); > WDYT? > I don't like ...
8 years, 9 months ago (2012-03-21 04:13:30 UTC) #9
akalin
On 2012/03/21 04:13:30, Ami Fischman wrote: > > > > So you can do: > ...
8 years, 9 months ago (2012-03-22 23:13:23 UTC) #10
willchan no longer on Chromium
Sorry for delaying you so long Ami, one last round before we make a call ...
8 years, 9 months ago (2012-03-22 23:53:31 UTC) #11
akalin
On Thu, Mar 22, 2012 at 4:51 PM, William Chan (陈智昌) <willchan@chromium.org>wrote: > Sorry for ...
8 years, 9 months ago (2012-03-22 23:56:09 UTC) #12
Ami GONE FROM CHROMIUM
On Fri, Mar 23, 2012 at 12:56 AM, Fred Akalin <akalin@chromium.org> wrote: > On Thu, ...
8 years, 9 months ago (2012-03-23 13:29:27 UTC) #13
akalin
this LGTM http://codereview.chromium.org/9717021/diff/26001/base/callback_unittest.cc File base/callback_unittest.cc (right): http://codereview.chromium.org/9717021/diff/26001/base/callback_unittest.cc#newcode129 base/callback_unittest.cc:129: cb(base::Bind(&TestForReentrancy::AssertCBIsNull, no base:: http://codereview.chromium.org/9717021/diff/26001/base/callback_unittest.cc#newcode130 base/callback_unittest.cc:130: base::Unretained(this))) { ...
8 years, 9 months ago (2012-03-23 18:42:07 UTC) #14
willchan no longer on Chromium
Please update the changelist description. I was actually fine with using another pump file and ...
8 years, 9 months ago (2012-03-23 20:59:20 UTC) #15
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/fischman@chromium.org/9717021/26004
8 years, 9 months ago (2012-03-24 17:42:57 UTC) #16
Ami GONE FROM CHROMIUM
Thanks for sticking with it. http://codereview.chromium.org/9717021/diff/26001/base/callback_unittest.cc File base/callback_unittest.cc (right): http://codereview.chromium.org/9717021/diff/26001/base/callback_unittest.cc#newcode129 base/callback_unittest.cc:129: cb(base::Bind(&TestForReentrancy::AssertCBIsNull, On 2012/03/23 18:42:07, ...
8 years, 9 months ago (2012-03-24 17:43:35 UTC) #17
commit-bot: I haz the power
8 years, 9 months ago (2012-03-24 20:37:31 UTC) #18
Change committed as 128772

Powered by Google App Engine
This is Rietveld 408576698