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

Side by Side Diff: base/callback_internal.cc

Issue 2042223002: Introduce OnceClosure and BindOnce (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: swap Once & Repeating positions Created 4 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
« no previous file with comments | « base/callback_internal.h ('k') | base/callback_unittest.nc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/callback_internal.h" 5 #include "base/callback_internal.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace base { 9 namespace base {
10 namespace internal { 10 namespace internal {
(...skipping 13 matching lines...) Expand all
24 void BindStateBase::Release() { 24 void BindStateBase::Release() {
25 if (!AtomicRefCountDec(&ref_count_)) 25 if (!AtomicRefCountDec(&ref_count_))
26 destructor_(this); 26 destructor_(this);
27 } 27 }
28 28
29 CallbackBase<CopyMode::MoveOnly>::CallbackBase(CallbackBase&& c) = default; 29 CallbackBase<CopyMode::MoveOnly>::CallbackBase(CallbackBase&& c) = default;
30 30
31 CallbackBase<CopyMode::MoveOnly>& 31 CallbackBase<CopyMode::MoveOnly>&
32 CallbackBase<CopyMode::MoveOnly>::operator=(CallbackBase&& c) = default; 32 CallbackBase<CopyMode::MoveOnly>::operator=(CallbackBase&& c) = default;
33 33
34 CallbackBase<CopyMode::MoveOnly>::CallbackBase(
35 const CallbackBase<CopyMode::Copyable>& c)
36 : bind_state_(c.bind_state_) {}
37
38 CallbackBase<CopyMode::MoveOnly>& CallbackBase<CopyMode::MoveOnly>::operator=(
39 const CallbackBase<CopyMode::Copyable>& c) {
40 bind_state_ = c.bind_state_;
41 return *this;
42 }
43
34 void CallbackBase<CopyMode::MoveOnly>::Reset() { 44 void CallbackBase<CopyMode::MoveOnly>::Reset() {
35 // NULL the bind_state_ last, since it may be holding the last ref to whatever 45 // NULL the bind_state_ last, since it may be holding the last ref to whatever
36 // object owns us, and we may be deleted after that. 46 // object owns us, and we may be deleted after that.
37 bind_state_ = nullptr; 47 bind_state_ = nullptr;
38 } 48 }
39 49
40 bool CallbackBase<CopyMode::MoveOnly>::IsCancelled() const { 50 bool CallbackBase<CopyMode::MoveOnly>::IsCancelled() const {
41 DCHECK(bind_state_); 51 DCHECK(bind_state_);
42 return bind_state_->IsCancelled(); 52 return bind_state_->IsCancelled();
43 } 53 }
(...skipping 26 matching lines...) Expand all
70 } 80 }
71 81
72 CallbackBase<CopyMode::Copyable>& 82 CallbackBase<CopyMode::Copyable>&
73 CallbackBase<CopyMode::Copyable>::operator=(CallbackBase&& c) = default; 83 CallbackBase<CopyMode::Copyable>::operator=(CallbackBase&& c) = default;
74 84
75 template class CallbackBase<CopyMode::MoveOnly>; 85 template class CallbackBase<CopyMode::MoveOnly>;
76 template class CallbackBase<CopyMode::Copyable>; 86 template class CallbackBase<CopyMode::Copyable>;
77 87
78 } // namespace internal 88 } // namespace internal
79 } // namespace base 89 } // namespace base
OLDNEW
« no previous file with comments | « base/callback_internal.h ('k') | base/callback_unittest.nc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698