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

Side by Side Diff: base/callback.h

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 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/bind_unittest.cc ('k') | base/callback_internal.h » ('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 #ifndef BASE_CALLBACK_H_ 5 #ifndef BASE_CALLBACK_H_
6 #define BASE_CALLBACK_H_ 6 #define BASE_CALLBACK_H_
7 7
8 #include "base/callback_forward.h" 8 #include "base/callback_forward.h"
9 #include "base/callback_internal.h" 9 #include "base/callback_internal.h"
10 10
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // 180 //
181 // void Foo(int* arg) { cout << *arg << endl; } 181 // void Foo(int* arg) { cout << *arg << endl; }
182 // int* pn = new int(1); 182 // int* pn = new int(1);
183 // base::Closure foo_callback = base::Bind(&foo, base::Owned(pn)); 183 // base::Closure foo_callback = base::Bind(&foo, base::Owned(pn));
184 // 184 //
185 // The parameter will be deleted when the callback is destroyed, even if it's 185 // The parameter will be deleted when the callback is destroyed, even if it's
186 // not run (like if you post a task during shutdown). 186 // not run (like if you post a task during shutdown).
187 // 187 //
188 // PASSING PARAMETERS AS A scoped_ptr 188 // PASSING PARAMETERS AS A scoped_ptr
189 // 189 //
190 // void TakesOwnership(scoped_ptr<Foo> arg) {} 190 // void TakesOwnership(std::unique_ptr<Foo> arg) {}
191 // scoped_ptr<Foo> f(new Foo); 191 // std::unique_ptr<Foo> f(new Foo);
192 // // f becomes null during the following call. 192 // // f becomes null during the following call.
193 // base::Closure cb = base::Bind(&TakesOwnership, base::Passed(&f)); 193 // base::Closure cb = base::Bind(&TakesOwnership, base::Passed(&f));
194 // 194 //
195 // Ownership of the parameter will be with the callback until the it is run, 195 // Ownership of the parameter will be with the callback until the it is run,
196 // when ownership is passed to the callback function. This means the callback 196 // when ownership is passed to the callback function. This means the callback
197 // can only be run once. If the callback is never run, it will delete the 197 // can only be run once. If the callback is never run, it will delete the
198 // object when it's destroyed. 198 // object when it's destroyed.
199 // 199 //
200 // PASSING PARAMETERS AS A scoped_refptr 200 // PASSING PARAMETERS AS A scoped_refptr
201 // 201 //
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 return f(this->bind_state_.get(), std::forward<Args>(args)...); 397 return f(this->bind_state_.get(), std::forward<Args>(args)...);
398 } 398 }
399 399
400 private: 400 private:
401 using PolymorphicInvoke = R (*)(internal::BindStateBase*, Args&&...); 401 using PolymorphicInvoke = R (*)(internal::BindStateBase*, Args&&...);
402 }; 402 };
403 403
404 } // namespace base 404 } // namespace base
405 405
406 #endif // BASE_CALLBACK_H_ 406 #endif // BASE_CALLBACK_H_
OLDNEW
« no previous file with comments | « base/bind_unittest.cc ('k') | base/callback_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698