Fix a bug where the JavaBridgeDispatcherHost is prematurely deleted

JavaBridgeDispatcherHost must be ref-counted because it is used with
base::Bind. http://codereview.chromium.org/8834013 changed
JavaBridgeDispatcherHost to also inherit from RenderViewHostObserver. The base
implementation of RenderViewHostObserver::RenderViewHostDestroyed() deletes the
object. This is unwanted in this class, so we provide an empy implementation of
the method.


Review URL: http://codereview.chromium.org/8929005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114218 0039d316-1c4b-4281-b951-d872f2087c98
parent a7505e26
...@@ -66,6 +66,12 @@ bool JavaBridgeDispatcherHost::Send(IPC::Message* msg) { ...@@ -66,6 +66,12 @@ bool JavaBridgeDispatcherHost::Send(IPC::Message* msg) {
return RenderViewHostObserver::Send(msg); return RenderViewHostObserver::Send(msg);
} }
void JavaBridgeDispatcherHost::RenderViewHostDestroyed() {
// Base implementation deletes the object. This class is ref counted, with
// refs held by the JavaBridgeDispatcherHostManager and base::Bind, so that
// behavior is unwanted.
}
bool JavaBridgeDispatcherHost::OnMessageReceived(const IPC::Message& msg) { bool JavaBridgeDispatcherHost::OnMessageReceived(const IPC::Message& msg) {
bool handled = true; bool handled = true;
IPC_BEGIN_MESSAGE_MAP(JavaBridgeDispatcherHost, msg) IPC_BEGIN_MESSAGE_MAP(JavaBridgeDispatcherHost, msg)
......
...@@ -39,9 +39,10 @@ class JavaBridgeDispatcherHost ...@@ -39,9 +39,10 @@ class JavaBridgeDispatcherHost
void AddNamedObject(const string16& name, NPObject* object); void AddNamedObject(const string16& name, NPObject* object);
void RemoveNamedObject(const string16& name); void RemoveNamedObject(const string16& name);
// RenderViewHostObserver override: // RenderViewHostObserver overrides:
// The IPC macros require this to be public. // The IPC macros require this to be public.
virtual bool Send(IPC::Message* msg) OVERRIDE; virtual bool Send(IPC::Message* msg) OVERRIDE;
virtual void RenderViewHostDestroyed() OVERRIDE;
private: private:
friend class base::RefCountedThreadSafe<JavaBridgeDispatcherHost>; friend class base::RefCountedThreadSafe<JavaBridgeDispatcherHost>;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment