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

Unified Diff: base/uber_callback_helpers.h

Issue 6109007: Unified callback system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/base
Patch Set: Fixing up some comments. Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
« base/uber_callback.h.pump ('K') | « base/uber_callback.h.pump ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/uber_callback_helpers.h
diff --git a/base/uber_callback_helpers.h b/base/uber_callback_helpers.h
new file mode 100644
index 0000000000000000000000000000000000000000..652880c95eea2d4358606f12d4b44c72a9e1f450
--- /dev/null
+++ b/base/uber_callback_helpers.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file contains utility functions and classes that help the implemenation,
+// and management of the Callback objects.
+
+#ifndef BASE_UBER_CALLBACK_HELPERS_H_
+#define BASE_UBER_CALLBACK_HELPERS_H_
+#pragma once
+
+#include "base/ref_counted.h"
+
+namespace base {
+namespace internal {
+
+// InvokerStorageBase is used to provide an opaque handle that the Callback
+// class can use to represent a function object with bound arguments. It
+// behaves as an existential type that is used by a corresponding
+// PolymorphicInvoke function to perform the function execution. This allows
+// us to shield the Callback class from the types of the bound argument via
+// "type erasure."
+//
+// TODO(ajwong): Explain the PolymorphicInvoke setup is more understandable
+// terms.
+class InvokerStorageBase : public RefCountedThreadSafe<InvokerStorageBase> {
+ protected:
+ friend class RefCountedThreadSafe<InvokerStorageBase>;
+ virtual ~InvokerStorageBase() {}
+};
+
+template <typename T>
+struct InvokerStorageHolder {
+ explicit InvokerStorageHolder(T* invoker_storage)
+ : invoker_storage_(invoker_storage) {
+ }
+ mutable scoped_refptr<InvokerStorageBase> invoker_storage_;
willchan no longer on Chromium 2011/02/06 10:26:50 in structs, you don't use the trailing underscore
+};
+
+template <typename T>
+InvokerStorageHolder<T> MakeInvokerStorageHolder(T* o) {
+ return InvokerStorageHolder<T>(o);
+}
+
+} // namespace internal
+} // namespace base
+
+#endif // BASE_UBER_CALLBACK_HELPERS_H_
« base/uber_callback.h.pump ('K') | « base/uber_callback.h.pump ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698