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

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

Issue 253013002: Pass RenderFrameHost to WebContentObservers' message handlers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typo in RenderHostTracker Created 6 years, 7 months 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_MANAGER_H _ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_MANAGER_H _
6 #define CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_MANAGER_H _ 6 #define CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_MANAGER_H _
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/android/jni_weak_ref.h" 10 #include "base/android/jni_weak_ref.h"
(...skipping 10 matching lines...) Expand all
21 class JavaBridgeDispatcherHost; 21 class JavaBridgeDispatcherHost;
22 class RenderFrameHost; 22 class RenderFrameHost;
23 23
24 // This class handles injecting Java objects into all of the RenderFrames 24 // This class handles injecting Java objects into all of the RenderFrames
25 // associated with a WebContents. It manages a set of JavaBridgeDispatcherHost 25 // associated with a WebContents. It manages a set of JavaBridgeDispatcherHost
26 // objects, one per RenderFrameHost. 26 // objects, one per RenderFrameHost.
27 class JavaBridgeDispatcherHostManager 27 class JavaBridgeDispatcherHostManager
28 : public WebContentsObserver, 28 : public WebContentsObserver,
29 public base::SupportsWeakPtr<JavaBridgeDispatcherHostManager> { 29 public base::SupportsWeakPtr<JavaBridgeDispatcherHostManager> {
30 public: 30 public:
31 explicit JavaBridgeDispatcherHostManager(WebContents* web_contents); 31 JavaBridgeDispatcherHostManager(WebContents* web_contents,
32 jobject retained_object_set);
32 virtual ~JavaBridgeDispatcherHostManager(); 33 virtual ~JavaBridgeDispatcherHostManager();
33 34
34 // These methods add or remove the object to each JavaBridgeDispatcherHost. 35 // These methods add or remove the object to each JavaBridgeDispatcherHost.
35 // Each one holds a reference to the NPObject while the object is bound to 36 // Each one holds a reference to the NPObject while the object is bound to
36 // the corresponding RenderFrame. See JavaBridgeDispatcherHost for details. 37 // the corresponding RenderFrame. See JavaBridgeDispatcherHost for details.
37 void AddNamedObject(const base::string16& name, NPObject* object); 38 void AddNamedObject(const base::string16& name, NPObject* object);
38 void RemoveNamedObject(const base::string16& name); 39 void RemoveNamedObject(const base::string16& name);
39 40
40 void OnGetChannelHandle(RenderFrameHost* render_frame_host,
41 IPC::Message* reply_msg);
42
43 // Every time a JavaBoundObject backed by a real Java object is
44 // created/destroyed, we insert/remove a strong ref to that Java object into
45 // this set so that it doesn't get garbage collected while it's still
46 // potentially in use. Although the set is managed native side, it's owned
47 // and defined in Java so that pushing refs into it does not create new GC
48 // roots that would prevent ContentViewCore from being garbage collected.
49 void SetRetainedObjectSet(const JavaObjectWeakGlobalRef& retained_object_set);
50
51 // WebContentsObserver overrides 41 // WebContentsObserver overrides
52 virtual void RenderFrameCreated(RenderFrameHost* render_frame_host) OVERRIDE; 42 virtual void RenderFrameCreated(RenderFrameHost* render_frame_host) OVERRIDE;
53 virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) OVERRIDE; 43 virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) OVERRIDE;
54 virtual void DocumentAvailableInMainFrame() OVERRIDE; 44 virtual void DocumentAvailableInMainFrame() OVERRIDE;
45 virtual bool OnMessageReceived(const IPC::Message& message,
46 RenderFrameHost* render_frame_host) OVERRIDE;
55 47
56 void JavaBoundObjectCreated(const base::android::JavaRef<jobject>& object); 48 void JavaBoundObjectCreated(const base::android::JavaRef<jobject>& object);
57 void JavaBoundObjectDestroyed(const base::android::JavaRef<jobject>& object); 49 void JavaBoundObjectDestroyed(const base::android::JavaRef<jobject>& object);
58 50
59 bool GetAllowObjectContentsInspection() const { 51 bool GetAllowObjectContentsInspection() const {
60 return allow_object_contents_inspection_; 52 return allow_object_contents_inspection_;
61 } 53 }
62 void SetAllowObjectContentsInspection(bool allow); 54 void SetAllowObjectContentsInspection(bool allow);
63 55
64 private: 56 private:
57
jam 2014/05/02 19:41:22 nit: without the blank line was conforming to the
mnaganov (inactive) 2014/05/06 09:06:46 Sorry, restored.
65 typedef std::map<RenderFrameHost*, scoped_refptr<JavaBridgeDispatcherHost> > 58 typedef std::map<RenderFrameHost*, scoped_refptr<JavaBridgeDispatcherHost> >
66 InstanceMap; 59 InstanceMap;
67 InstanceMap instances_; 60 InstanceMap instances_;
68 typedef std::map<base::string16, NPObject*> ObjectMap; 61 typedef std::map<base::string16, NPObject*> ObjectMap;
69 ObjectMap objects_; 62 ObjectMap objects_;
63 // Every time a JavaBoundObject backed by a real Java object is
64 // created/destroyed, we insert/remove a strong ref to that Java object into
65 // this set so that it doesn't get garbage collected while it's still
66 // potentially in use. Although the set is managed native side, it's owned
67 // and defined in Java so that pushing refs into it does not create new GC
68 // roots that would prevent ContentViewCore from being garbage collected.
70 JavaObjectWeakGlobalRef retained_object_set_; 69 JavaObjectWeakGlobalRef retained_object_set_;
71 bool allow_object_contents_inspection_; 70 bool allow_object_contents_inspection_;
72 71
73 DISALLOW_COPY_AND_ASSIGN(JavaBridgeDispatcherHostManager); 72 DISALLOW_COPY_AND_ASSIGN(JavaBridgeDispatcherHostManager);
74 }; 73 };
75 74
76 } // namespace content 75 } // namespace content
77 76
78 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_MANAGE R_H_ 77 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_MANAGE R_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698