Make AsyncExtensionFunction possible.
Change the bookmarks API to be async functions, so that they can delay their
response until the bookmark system is loaded.
BUG=12353
TEST=none
Review URL: http://codereview.chromium.org/114079
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17751 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extension_function_dispatcher.h b/chrome/browser/extensions/extension_function_dispatcher.h
index a9af552..8375ae4 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.h
+++ b/chrome/browser/extensions/extension_function_dispatcher.h
@@ -9,6 +9,7 @@
#include <string>
#include <vector>
+#include "base/ref_counted.h"
#include "base/values.h"
class Browser;
@@ -30,6 +31,13 @@
virtual Browser* GetBrowser() = 0;
};
+ // The peer object allows us to notify ExtensionFunctions when we are
+ // destroyed.
+ struct Peer : public base::RefCounted<Peer> {
+ Peer(ExtensionFunctionDispatcher* dispatcher) : dispatcher_(dispatcher) {}
+ ExtensionFunctionDispatcher* dispatcher_;
+ };
+
// Gets a list of all known extension function names.
static void GetAllFunctionNames(std::vector<std::string>* names);
@@ -44,6 +52,7 @@
ExtensionFunctionDispatcher(RenderViewHost* render_view_host,
Delegate* delegate,
const std::string& extension_id);
+ ~ExtensionFunctionDispatcher();
// Handle a request to execute an extension function.
void HandleRequest(const std::string& name, const std::string& args,
@@ -73,6 +82,8 @@
std::string extension_id_;
+ scoped_refptr<Peer> peer_;
+
// AutomationExtensionFunction requires access to the RenderViewHost
// associated with us. We make it a friend rather than exposing the
// RenderViewHost as a public method as we wouldn't want everyone to