OLD | NEW |
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_helper.h" | 10 #include "base/android/jni_helper.h" |
(...skipping 16 matching lines...) Expand all Loading... |
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 explicit JavaBridgeDispatcherHostManager(WebContents* web_contents); |
32 virtual ~JavaBridgeDispatcherHostManager(); | 32 virtual ~JavaBridgeDispatcherHostManager(); |
33 | 33 |
34 // These methods add or remove the object to each JavaBridgeDispatcherHost. | 34 // 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 | 35 // Each one holds a reference to the NPObject while the object is bound to |
36 // the corresponding RenderView. See JavaBridgeDispatcherHost for details. | 36 // the corresponding RenderView. See JavaBridgeDispatcherHost for details. |
37 void AddNamedObject(const string16& name, NPObject* object); | 37 void AddNamedObject(const base::string16& name, NPObject* object); |
38 void RemoveNamedObject(const string16& name); | 38 void RemoveNamedObject(const base::string16& name); |
39 | 39 |
40 void OnGetChannelHandle(RenderViewHost* render_view_host, | 40 void OnGetChannelHandle(RenderViewHost* render_view_host, |
41 IPC::Message* reply_msg); | 41 IPC::Message* reply_msg); |
42 | 42 |
43 // Every time a JavaBoundObject backed by a real Java object is | 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 | 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 | 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 | 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 | 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. | 48 // roots that would prevent ContentViewCore from being garbage collected. |
49 void SetRetainedObjectSet(const JavaObjectWeakGlobalRef& retained_object_set); | 49 void SetRetainedObjectSet(const JavaObjectWeakGlobalRef& retained_object_set); |
50 | 50 |
51 // WebContentsObserver overrides | 51 // WebContentsObserver overrides |
52 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; | 52 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; |
53 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; | 53 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; |
54 virtual void DocumentAvailableInMainFrame() OVERRIDE; | 54 virtual void DocumentAvailableInMainFrame() OVERRIDE; |
55 | 55 |
56 void JavaBoundObjectCreated(const base::android::JavaRef<jobject>& object); | 56 void JavaBoundObjectCreated(const base::android::JavaRef<jobject>& object); |
57 void JavaBoundObjectDestroyed(const base::android::JavaRef<jobject>& object); | 57 void JavaBoundObjectDestroyed(const base::android::JavaRef<jobject>& object); |
58 | 58 |
59 private: | 59 private: |
60 typedef std::map<RenderViewHost*, scoped_refptr<JavaBridgeDispatcherHost> > | 60 typedef std::map<RenderViewHost*, scoped_refptr<JavaBridgeDispatcherHost> > |
61 InstanceMap; | 61 InstanceMap; |
62 InstanceMap instances_; | 62 InstanceMap instances_; |
63 typedef std::map<string16, NPObject*> ObjectMap; | 63 typedef std::map<base::string16, NPObject*> ObjectMap; |
64 ObjectMap objects_; | 64 ObjectMap objects_; |
65 JavaObjectWeakGlobalRef retained_object_set_; | 65 JavaObjectWeakGlobalRef retained_object_set_; |
66 | 66 |
67 DISALLOW_COPY_AND_ASSIGN(JavaBridgeDispatcherHostManager); | 67 DISALLOW_COPY_AND_ASSIGN(JavaBridgeDispatcherHostManager); |
68 }; | 68 }; |
69 | 69 |
70 } // namespace content | 70 } // namespace content |
71 | 71 |
72 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_MANAGE
R_H_ | 72 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_MANAGE
R_H_ |
OLD | NEW |