summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_function_dispatcher.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/extensions/extension_function_dispatcher.cc')
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index 93a34db..6e560e16 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -172,7 +172,8 @@ ExtensionFunctionDispatcher::ExtensionFunctionDispatcher(
const std::string& extension_id)
: render_view_host_(render_view_host),
delegate_(delegate),
- extension_id_(extension_id) {
+ extension_id_(extension_id),
+ ALLOW_THIS_IN_INITIALIZER_LIST(peer_(new Peer(this))) {
RenderProcessHost* process = render_view_host_->process();
ExtensionMessageService* message_service =
ExtensionMessageService::GetInstance(profile()->GetRequestContext());
@@ -181,6 +182,10 @@ ExtensionFunctionDispatcher::ExtensionFunctionDispatcher(
message_service->RegisterExtension(extension_id, process->pid());
}
+ExtensionFunctionDispatcher::~ExtensionFunctionDispatcher() {
+ peer_->dispatcher_ = NULL;
+}
+
Browser* ExtensionFunctionDispatcher::GetBrowser() {
DCHECK(delegate_);
@@ -192,11 +197,9 @@ void ExtensionFunctionDispatcher::HandleRequest(const std::string& name,
const std::string& args,
int request_id,
bool has_callback) {
- // TODO(aa): This will get a bit more complicated when we support functions
- // that live longer than the stack frame.
- scoped_ptr<ExtensionFunction> function(
+ scoped_refptr<ExtensionFunction> function(
FactoryRegistry::instance()->NewFunction(name));
- function->set_dispatcher(this);
+ function->set_dispatcher_peer(peer_);
function->SetArgs(args);
function->set_request_id(request_id);
function->set_has_callback(has_callback);