OLD | NEW |
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 // This file contains utility functions and classes that help the | 5 // This file contains utility functions and classes that help the |
6 // implementation, and management of the Callback objects. | 6 // implementation, and management of the Callback objects. |
7 | 7 |
8 #ifndef BASE_CALLBACK_INTERNAL_H_ | 8 #ifndef BASE_CALLBACK_INTERNAL_H_ |
9 #define BASE_CALLBACK_INTERNAL_H_ | 9 #define BASE_CALLBACK_INTERNAL_H_ |
10 #pragma once | 10 #pragma once |
11 | 11 |
12 #include <stddef.h> | 12 #include <stddef.h> |
13 | 13 |
14 #include "base/base_api.h" | 14 #include "base/base_export.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 namespace internal { | 18 namespace internal { |
19 | 19 |
20 // InvokerStorageBase is used to provide an opaque handle that the Callback | 20 // InvokerStorageBase is used to provide an opaque handle that the Callback |
21 // class can use to represent a function object with bound arguments. It | 21 // class can use to represent a function object with bound arguments. It |
22 // behaves as an existential type that is used by a corresponding | 22 // behaves as an existential type that is used by a corresponding |
23 // DoInvoke function to perform the function execution. This allows | 23 // DoInvoke function to perform the function execution. This allows |
24 // us to shield the Callback class from the types of the bound argument via | 24 // us to shield the Callback class from the types of the bound argument via |
(...skipping 22 matching lines...) Expand all Loading... |
47 mutable scoped_refptr<InvokerStorageBase> invoker_storage_; | 47 mutable scoped_refptr<InvokerStorageBase> invoker_storage_; |
48 }; | 48 }; |
49 | 49 |
50 template <typename T> | 50 template <typename T> |
51 InvokerStorageHolder<T> MakeInvokerStorageHolder(T* o) { | 51 InvokerStorageHolder<T> MakeInvokerStorageHolder(T* o) { |
52 return InvokerStorageHolder<T>(o); | 52 return InvokerStorageHolder<T>(o); |
53 } | 53 } |
54 | 54 |
55 // Holds the Callback methods that don't require specialization to reduce | 55 // Holds the Callback methods that don't require specialization to reduce |
56 // template bloat. | 56 // template bloat. |
57 class BASE_API CallbackBase { | 57 class BASE_EXPORT CallbackBase { |
58 public: | 58 public: |
59 // Returns true if Callback is null (doesn't refer to anything). | 59 // Returns true if Callback is null (doesn't refer to anything). |
60 bool is_null() const; | 60 bool is_null() const; |
61 | 61 |
62 // Returns the Callback into an uninitalized state. | 62 // Returns the Callback into an uninitalized state. |
63 void Reset(); | 63 void Reset(); |
64 | 64 |
65 bool Equals(const CallbackBase& other) const; | 65 bool Equals(const CallbackBase& other) const; |
66 | 66 |
67 protected: | 67 protected: |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 template <typename T> | 126 template <typename T> |
127 struct ParamTraits<T[]> { | 127 struct ParamTraits<T[]> { |
128 typedef const T* ForwardType; | 128 typedef const T* ForwardType; |
129 typedef const T* StorageType; | 129 typedef const T* StorageType; |
130 }; | 130 }; |
131 | 131 |
132 } // namespace internal | 132 } // namespace internal |
133 } // namespace base | 133 } // namespace base |
134 | 134 |
135 #endif // BASE_CALLBACK_INTERNAL_H_ | 135 #endif // BASE_CALLBACK_INTERNAL_H_ |
OLD | NEW |