| 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 "base/base_api.h" |
| 12 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 namespace internal { | 16 namespace internal { |
| 16 | 17 |
| 17 // InvokerStorageBase is used to provide an opaque handle that the Callback | 18 // 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 // 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 // behaves as an existential type that is used by a corresponding |
| 20 // DoInvoke function to perform the function execution. This allows | 21 // DoInvoke function to perform the function execution. This allows |
| 21 // us to shield the Callback class from the types of the bound argument via | 22 // us to shield the Callback class from the types of the bound argument via |
| (...skipping 22 matching lines...) Expand all Loading... |
| 44 mutable scoped_refptr<InvokerStorageBase> invoker_storage_; | 45 mutable scoped_refptr<InvokerStorageBase> invoker_storage_; |
| 45 }; | 46 }; |
| 46 | 47 |
| 47 template <typename T> | 48 template <typename T> |
| 48 InvokerStorageHolder<T> MakeInvokerStorageHolder(T* o) { | 49 InvokerStorageHolder<T> MakeInvokerStorageHolder(T* o) { |
| 49 return InvokerStorageHolder<T>(o); | 50 return InvokerStorageHolder<T>(o); |
| 50 } | 51 } |
| 51 | 52 |
| 52 // Holds the Callback methods that don't require specialization to reduce | 53 // Holds the Callback methods that don't require specialization to reduce |
| 53 // template bloat. | 54 // template bloat. |
| 54 class CallbackBase { | 55 class BASE_API CallbackBase { |
| 55 public: | 56 public: |
| 56 // Returns true if Callback is null (doesn't refer to anything). | 57 // Returns true if Callback is null (doesn't refer to anything). |
| 57 bool is_null() const; | 58 bool is_null() const; |
| 58 | 59 |
| 59 // Returns the Callback into an uninitalized state. | 60 // Returns the Callback into an uninitalized state. |
| 60 void Reset(); | 61 void Reset(); |
| 61 | 62 |
| 62 bool Equals(const CallbackBase& other) const; | 63 bool Equals(const CallbackBase& other) const; |
| 63 | 64 |
| 64 protected: | 65 protected: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 77 ~CallbackBase(); | 78 ~CallbackBase(); |
| 78 | 79 |
| 79 scoped_refptr<InvokerStorageBase> invoker_storage_; | 80 scoped_refptr<InvokerStorageBase> invoker_storage_; |
| 80 InvokeFuncStorage polymorphic_invoke_; | 81 InvokeFuncStorage polymorphic_invoke_; |
| 81 }; | 82 }; |
| 82 | 83 |
| 83 } // namespace internal | 84 } // namespace internal |
| 84 } // namespace base | 85 } // namespace base |
| 85 | 86 |
| 86 #endif // BASE_CALLBACK_INTERNAL_H_ | 87 #endif // BASE_CALLBACK_INTERNAL_H_ |
| OLD | NEW |