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

Side by Side Diff: base/memory/scoped_callback_factory.h

Issue 6985009: iwyu: Use callback_old.h where appropriate, part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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
« no previous file with comments | « base/file_util_proxy.h ('k') | base/observer_list_threadsafe.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // ScopedCallbackFactory helps in cases where you wish to allocate a Callback 5 // ScopedCallbackFactory helps in cases where you wish to allocate a Callback
6 // (see base/callback.h), but need to prevent any pending callbacks from 6 // (see base/callback.h), but need to prevent any pending callbacks from
7 // executing when your object gets destroyed. 7 // executing when your object gets destroyed.
8 // 8 //
9 // EXAMPLE: 9 // EXAMPLE:
10 // 10 //
(...skipping 18 matching lines...) Expand all
29 // 29 //
30 // In the above example, the Process function calls GatherDataAsynchronously to 30 // In the above example, the Process function calls GatherDataAsynchronously to
31 // kick off some asynchronous processing that upon completion will notify a 31 // kick off some asynchronous processing that upon completion will notify a
32 // callback. If in the meantime, the MyClass instance is destroyed, when the 32 // callback. If in the meantime, the MyClass instance is destroyed, when the
33 // callback runs, it will notice that the MyClass instance is dead, and it will 33 // callback runs, it will notice that the MyClass instance is dead, and it will
34 // avoid calling the GotData method. 34 // avoid calling the GotData method.
35 35
36 #ifndef BASE_MEMORY_SCOPED_CALLBACK_FACTORY_H_ 36 #ifndef BASE_MEMORY_SCOPED_CALLBACK_FACTORY_H_
37 #define BASE_MEMORY_SCOPED_CALLBACK_FACTORY_H_ 37 #define BASE_MEMORY_SCOPED_CALLBACK_FACTORY_H_
38 38
39 #include "base/callback.h" 39 #include "base/callback_old.h"
40 #include "base/memory/weak_ptr.h" 40 #include "base/memory/weak_ptr.h"
41 41
42 namespace base { 42 namespace base {
43 43
44 template <class T> 44 template <class T>
45 class ScopedCallbackFactory { 45 class ScopedCallbackFactory {
46 public: 46 public:
47 explicit ScopedCallbackFactory(T* obj) : weak_factory_(obj) { 47 explicit ScopedCallbackFactory(T* obj) : weak_factory_(obj) {
48 } 48 }
49 49
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 DispatchToMethod(this->obj_.get(), this->meth_, params); 124 DispatchToMethod(this->obj_.get(), this->meth_, params);
125 } 125 }
126 }; 126 };
127 127
128 WeakPtrFactory<T> weak_factory_; 128 WeakPtrFactory<T> weak_factory_;
129 }; 129 };
130 130
131 } // namespace base 131 } // namespace base
132 132
133 #endif // BASE_MEMORY_SCOPED_CALLBACK_FACTORY_H_ 133 #endif // BASE_MEMORY_SCOPED_CALLBACK_FACTORY_H_
OLDNEW
« no previous file with comments | « base/file_util_proxy.h ('k') | base/observer_list_threadsafe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698