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

Side by Side Diff: base/callback_helpers.h

Issue 1538743002: Switch to standard integer types in base/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DEPS roll too Created 4 years, 12 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/bits_unittest.cc ('k') | base/callback_list.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 // This defines helpful methods for dealing with Callbacks. Because Callbacks 5 // This defines helpful methods for dealing with Callbacks. Because Callbacks
6 // are implemented using templates, with a class per callback signature, adding 6 // are implemented using templates, with a class per callback signature, adding
7 // methods to Callback<> itself is unattractive (lots of extra code gets 7 // methods to Callback<> itself is unattractive (lots of extra code gets
8 // generated). Instead, consider adding methods here. 8 // generated). Instead, consider adding methods here.
9 // 9 //
10 // ResetAndReturn(&cb) is like cb.Reset() but allows executing a callback (via a 10 // ResetAndReturn(&cb) is like cb.Reset() but allows executing a callback (via a
11 // copy) after the original callback is Reset(). This can be handy if Run() 11 // copy) after the original callback is Reset(). This can be handy if Run()
12 // reads/writes the variable holding the Callback. 12 // reads/writes the variable holding the Callback.
13 13
14 #ifndef BASE_CALLBACK_HELPERS_H_ 14 #ifndef BASE_CALLBACK_HELPERS_H_
15 #define BASE_CALLBACK_HELPERS_H_ 15 #define BASE_CALLBACK_HELPERS_H_
16 16
17 #include "base/basictypes.h"
18 #include "base/callback.h" 17 #include "base/callback.h"
19 #include "base/compiler_specific.h" 18 #include "base/compiler_specific.h"
19 #include "base/macros.h"
20 20
21 namespace base { 21 namespace base {
22 22
23 template <typename Sig> 23 template <typename Sig>
24 base::Callback<Sig> ResetAndReturn(base::Callback<Sig>* cb) { 24 base::Callback<Sig> ResetAndReturn(base::Callback<Sig>* cb) {
25 base::Callback<Sig> ret(*cb); 25 base::Callback<Sig> ret(*cb);
26 cb->Reset(); 26 cb->Reset();
27 return ret; 27 return ret;
28 } 28 }
29 29
(...skipping 11 matching lines...) Expand all
41 41
42 private: 42 private:
43 Closure closure_; 43 Closure closure_;
44 44
45 DISALLOW_COPY_AND_ASSIGN(ScopedClosureRunner); 45 DISALLOW_COPY_AND_ASSIGN(ScopedClosureRunner);
46 }; 46 };
47 47
48 } // namespace base 48 } // namespace base
49 49
50 #endif // BASE_CALLBACK_HELPERS_H_ 50 #endif // BASE_CALLBACK_HELPERS_H_
OLDNEW
« no previous file with comments | « base/bits_unittest.cc ('k') | base/callback_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698