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

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

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 #ifndef CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
11 #include "content/browser/renderer_host/render_view_host_observer.h" 11 #include "content/browser/renderer_host/render_view_host_observer.h"
12 12
13 class NPChannelBase; 13 class NPChannelBase;
14 class RenderViewHost; 14 class RenderViewHost;
15 class RouteIDGenerator; 15 class RouteIDGenerator;
16 struct NPObject; 16 struct NPObject;
17 struct NPVariant_Param; 17 struct NPVariant_Param;
18 18
19 // This class handles injecting Java objects into a single RenderView. The Java 19 // This class handles injecting Java objects into a single RenderView. The Java
20 // object itself lives in the browser process on a background thread, while a 20 // object itself lives in the browser process on a background thread, while a
21 // proxy object is created in the renderer. An instance of this class exists 21 // proxy object is created in the renderer. An instance of this class exists
22 // for each RenderViewHost. 22 // for each RenderViewHost.
23 class JavaBridgeDispatcherHost 23 class JavaBridgeDispatcherHost
24 : public base::RefCountedThreadSafe<JavaBridgeDispatcherHost>, 24 : public base::RefCountedThreadSafe<JavaBridgeDispatcherHost>,
25 public RenderViewHostObserver { 25 public RenderViewHostObserver {
joth 2011/12/13 11:50:43 multiple behavior inheritance: this is not strictl
26 public: 26 public:
27 // We hold a weak pointer to the RenderViewhost. It must outlive this object. 27 // We hold a weak pointer to the RenderViewhost. It must outlive this object.
28 JavaBridgeDispatcherHost(RenderViewHost* render_view_host); 28 JavaBridgeDispatcherHost(RenderViewHost* render_view_host);
29 29
30 // Injects |object| into the main frame of the corresponding RenderView. A 30 // Injects |object| into the main frame of the corresponding RenderView. A
31 // proxy object is created in the renderer and when the main frame's window 31 // proxy object is created in the renderer and when the main frame's window
32 // object is next cleared, this proxy object is bound to the window object 32 // object is next cleared, this proxy object is bound to the window object
33 // using |name|. The proxy object remains bound until the next time the 33 // using |name|. The proxy object remains bound until the next time the
34 // window object is cleared after a call to RemoveNamedObject() or 34 // window object is cleared after a call to RemoveNamedObject() or
35 // AddNamedObject() with the same name. The proxy object proxies calls back 35 // AddNamedObject() with the same name. The proxy object proxies calls back
36 // to |object|, which is manipulated on the background thread. This class 36 // to |object|, which is manipulated on the background thread. This class
37 // holds a reference to |object| for the time that the proxy object is bound 37 // holds a reference to |object| for the time that the proxy object is bound
38 // to the window object. 38 // to the window object.
39 void AddNamedObject(const string16& name, NPObject* object); 39 void AddNamedObject(const string16& name, NPObject* object);
40 void RemoveNamedObject(const string16& name); 40 void RemoveNamedObject(const string16& name);
41 41
42 // RenderViewHostObserver override: 42 // RenderViewHostObserver overrides:
43 // The IPC macros require this to be public. 43 // The IPC macros require this to be public.
44 virtual bool Send(IPC::Message* msg) OVERRIDE; 44 virtual bool Send(IPC::Message* msg) OVERRIDE;
45 virtual void RenderViewHostDestroyed() OVERRIDE;
45 46
46 private: 47 private:
47 friend class base::RefCountedThreadSafe<JavaBridgeDispatcherHost>; 48 friend class base::RefCountedThreadSafe<JavaBridgeDispatcherHost>;
48 ~JavaBridgeDispatcherHost(); 49 ~JavaBridgeDispatcherHost();
49 50
50 // RenderViewHostObserver override: 51 // RenderViewHostObserver override:
51 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 52 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
52 53
53 // Message handlers 54 // Message handlers
54 void OnGetChannelHandle(IPC::Message* reply_msg); 55 void OnGetChannelHandle(IPC::Message* reply_msg);
55 56
56 void GetChannelHandle(IPC::Message* reply_msg); 57 void GetChannelHandle(IPC::Message* reply_msg);
57 void CreateNPVariantParam(NPObject* object, NPVariant_Param* param); 58 void CreateNPVariantParam(NPObject* object, NPVariant_Param* param);
58 void CreateObjectStub(NPObject* object, int route_id); 59 void CreateObjectStub(NPObject* object, int route_id);
59 60
60 scoped_refptr<NPChannelBase> channel_; 61 scoped_refptr<NPChannelBase> channel_;
61 bool is_renderer_initialized_; 62 bool is_renderer_initialized_;
62 63
63 DISALLOW_COPY_AND_ASSIGN(JavaBridgeDispatcherHost); 64 DISALLOW_COPY_AND_ASSIGN(JavaBridgeDispatcherHost);
64 }; 65 };
65 66
66 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_H_ 67 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698