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

Side by Side Diff: cc/resources/scoped_release_callback.cc

Issue 23648014: cc: Move TextureMailbox::ReleaseCallback to SingleReleaseCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: releasecallback: missingfiles Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/resources/scoped_release_callback.h"
6
7 #include "base/callback_helpers.h"
8 #include "base/logging.h"
9
10 namespace cc {
11
12 ScopedReleaseCallback::ScopedReleaseCallback() {}
13
14 ScopedReleaseCallback::ScopedReleaseCallback(const ReleaseCallback& callback)
awong 2013/09/13 07:07:19 Doesn't this already violate the rule that there c
danakj 2013/09/13 17:32:59 Well, the callback has to come from somewhere. I'd
15 : callback_(callback) {}
16
17 ScopedReleaseCallback::ScopedReleaseCallback(RValue other)
18 : callback_(base::ResetAndReturn(&other.object->callback_)) {}
piman 2013/09/13 06:08:30 nit: callback_(other.object->Leak())
19
20 ScopedReleaseCallback::~ScopedReleaseCallback() {
21 DCHECK(callback_.is_null()) << "ScopedReleaseCallback was never run.";
22 }
23
24 void ScopedReleaseCallback::RunAndReset(unsigned sync_point, bool is_lost) {
25 base::ResetAndReturn(&callback_).Run(sync_point, is_lost);
26 }
27
28 ScopedReleaseCallback& ScopedReleaseCallback::operator=(
29 ScopedReleaseCallback rhs) {
30 DCHECK(callback_.is_null());
31 callback_ = rhs.callback_;
32 rhs.callback_ = ReleaseCallback();
piman 2013/09/13 06:08:30 nit: replace those 2 lines by callback_ = rhs.Leak
33 return *this;
34 }
35
36 ReleaseCallback ScopedReleaseCallback::Leak() {
37 return base::ResetAndReturn(&callback_);
38 }
39
40 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698