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

Side by Side Diff: content/browser/renderer_host/java/java_bridge_dispatcher_host.cc

Issue 8929005: Fix a bug where the JavaBridgeDispatcherHost is prematurely deleted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host.h" 5 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "content/browser/renderer_host/java/java_bridge_channel_host.h" 10 #include "content/browser/renderer_host/java/java_bridge_channel_host.h"
(...skipping 30 matching lines...) Expand all
41 JavaBridgeDispatcherHost::~JavaBridgeDispatcherHost() { 41 JavaBridgeDispatcherHost::~JavaBridgeDispatcherHost() {
42 } 42 }
43 43
44 void JavaBridgeDispatcherHost::AddNamedObject(const string16& name, 44 void JavaBridgeDispatcherHost::AddNamedObject(const string16& name,
45 NPObject* object) { 45 NPObject* object) {
46 NPVariant_Param variant_param; 46 NPVariant_Param variant_param;
47 CreateNPVariantParam(object, &variant_param); 47 CreateNPVariantParam(object, &variant_param);
48 48
49 if (!is_renderer_initialized_) { 49 if (!is_renderer_initialized_) {
50 is_renderer_initialized_ = true; 50 is_renderer_initialized_ = true;
51 Send(new JavaBridgeMsg_Init(routing_id())); 51 Send(new JavaBridgeMsg_Init(routing_id()));
joth 2011/12/13 11:50:43 note the RVH may have gone away (due to ref-count
Steve Block 2011/12/13 12:40:20 I don't think this is a problem, as the JavaBridge
52 } 52 }
53 Send(new JavaBridgeMsg_AddNamedObject(routing_id(), name, variant_param)); 53 Send(new JavaBridgeMsg_AddNamedObject(routing_id(), name, variant_param));
54 } 54 }
55 55
56 void JavaBridgeDispatcherHost::RemoveNamedObject(const string16& name) { 56 void JavaBridgeDispatcherHost::RemoveNamedObject(const string16& name) {
57 // On receipt of this message, the JavaBridgeDispatcher will drop its 57 // On receipt of this message, the JavaBridgeDispatcher will drop its
58 // reference to the corresponding proxy object. When the last reference is 58 // reference to the corresponding proxy object. When the last reference is
59 // removed, the proxy object will delete its NPObjectProxy, which will cause 59 // removed, the proxy object will delete its NPObjectProxy, which will cause
60 // the NPObjectStub to be deleted, which will drop its reference to the 60 // the NPObjectStub to be deleted, which will drop its reference to the
61 // original NPObject. 61 // original NPObject.
62 Send(new JavaBridgeMsg_RemoveNamedObject(routing_id(), name)); 62 Send(new JavaBridgeMsg_RemoveNamedObject(routing_id(), name));
63 } 63 }
64 64
65 bool JavaBridgeDispatcherHost::Send(IPC::Message* msg) { 65 bool JavaBridgeDispatcherHost::Send(IPC::Message* msg) {
joth 2011/12/13 11:50:43 aside (not for this CL) - is this Send() override
Steve Block 2011/12/13 12:40:20 Yes, I think it is, as we need to make Send() publ
66 return RenderViewHostObserver::Send(msg); 66 return RenderViewHostObserver::Send(msg);
67 } 67 }
68 68
69 void JavaBridgeDispatcherHost::RenderViewHostDestroyed() {
70 // Base implementation deletes the object. This class is ref counted, with
71 // refs held by the JavaBridgeDispatcherHostManager and base::Bind, so this
joth 2011/12/13 11:50:43 nit: this behavior -> that behavior.
Steve Block 2011/12/13 12:40:20 Done.
72 // behavior is unwanted.
73 }
74
69 bool JavaBridgeDispatcherHost::OnMessageReceived(const IPC::Message& msg) { 75 bool JavaBridgeDispatcherHost::OnMessageReceived(const IPC::Message& msg) {
70 bool handled = true; 76 bool handled = true;
71 IPC_BEGIN_MESSAGE_MAP(JavaBridgeDispatcherHost, msg) 77 IPC_BEGIN_MESSAGE_MAP(JavaBridgeDispatcherHost, msg)
72 IPC_MESSAGE_HANDLER_DELAY_REPLY(JavaBridgeHostMsg_GetChannelHandle, 78 IPC_MESSAGE_HANDLER_DELAY_REPLY(JavaBridgeHostMsg_GetChannelHandle,
73 OnGetChannelHandle) 79 OnGetChannelHandle)
74 IPC_MESSAGE_UNHANDLED(handled = false) 80 IPC_MESSAGE_UNHANDLED(handled = false)
75 IPC_END_MESSAGE_MAP() 81 IPC_END_MESSAGE_MAP()
76 return handled; 82 return handled;
77 } 83 }
78 84
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 133
128 // NPObjectStub takes a ref to the NPObject. The lifetime of the NPObjectStub 134 // NPObjectStub takes a ref to the NPObject. The lifetime of the NPObjectStub
129 // is governed by that of the NPObjectProxy in the renderer, via the channel. 135 // is governed by that of the NPObjectProxy in the renderer, via the channel.
130 // We don't need the containing window or the page URL, as we don't do 136 // We don't need the containing window or the page URL, as we don't do
131 // re-entrant sync IPC. 137 // re-entrant sync IPC.
132 new NPObjectStub(object, channel_, route_id, 0, GURL()); 138 new NPObjectStub(object, channel_, route_id, 0, GURL());
133 // The NPObjectStub takes a reference to the NPObject. Release the ref added 139 // The NPObjectStub takes a reference to the NPObject. Release the ref added
134 // in CreateNPVariantParam(). 140 // in CreateNPVariantParam().
135 WebKit::WebBindings::releaseObject(object); 141 WebKit::WebBindings::releaseObject(object);
136 } 142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698