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

Side by Side Diff: base/uber_callback_helpers.h

Issue 6109007: Unified callback system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/base
Patch Set: more bits of cleanup Created 9 years, 10 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
« base/uber_callback.h ('K') | « base/uber_callback.h.pump ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // This file contains utility functions and classes that help the implemenation,
6 // and management of the Callback objects.
7
8 #ifndef BASE_UBER_CALLBACK_HELPERS_H_
9 #define BASE_UBER_CALLBACK_HELPERS_H_
10 #pragma once
11
12 #include "base/ref_counted.h"
13
14 namespace base {
15 namespace internal {
16
17 // InvokerStorageBase is used to provide an opaque handle that the Callback
18 // class can use to represent a function object with bound arguments. It
19 // behaves as an existential type that is used by a corresponding
20 // PolymorphicInvoke function to perform the function execution. This allows
21 // us to shield the Callback class from the types of the bound argument via
22 // "type erasure."
23 class InvokerStorageBase : public RefCountedThreadSafe<InvokerStorageBase> {
24 protected:
25 friend class RefCountedThreadSafe<InvokerStorageBase>;
26 virtual ~InvokerStorageBase() {}
27 };
28
29 template <typename T>
30 struct InvokerStorageHolder {
31 explicit InvokerStorageHolder(T* invoker_storage)
32 : invoker_storage_(invoker_storage) {
33 }
willchan no longer on Chromium 2011/02/07 23:25:15 Perhaps the destructor should DCHECK that invoker_
awong 2011/02/08 18:52:26 We could...but then we'd be adding a non-trivial d
34 mutable scoped_refptr<InvokerStorageBase> invoker_storage_;
willchan no longer on Chromium 2011/02/06 10:26:50 Why is this mutable?
awong 2011/02/08 18:52:26 Added comment explaining.
35 };
36
37 template <typename T>
38 InvokerStorageHolder<T> MakeInvokerStorageHolder(T* o) {
39 return InvokerStorageHolder<T>(o);
40 }
41
42 } // namespace internal
43 } // namespace base
44
45 #endif // BASE_UBER_CALLBACK_HELPERS_H_
OLDNEW
« base/uber_callback.h ('K') | « base/uber_callback.h.pump ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698