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

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

Issue 9600036: Move Render(View|Widget)Host and associated classes to content namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments. Created 8 years, 9 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_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/public/browser/render_view_host_observer.h" 11 #include "content/public/browser/render_view_host_observer.h"
12 12
13 class NPChannelBase; 13 class NPChannelBase;
14 class RenderViewHost;
15 class RouteIDGenerator; 14 class RouteIDGenerator;
16 struct NPObject; 15 struct NPObject;
17 struct NPVariant_Param; 16 struct NPVariant_Param;
18 17
18 namespace content {
19 class RenderViewHost;
20 }
21
19 // This class handles injecting Java objects into a single RenderView. The Java 22 // 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 23 // 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 24 // proxy object is created in the renderer. An instance of this class exists
22 // for each RenderViewHost. 25 // for each RenderViewHost.
23 class JavaBridgeDispatcherHost 26 class JavaBridgeDispatcherHost
24 : public base::RefCountedThreadSafe<JavaBridgeDispatcherHost>, 27 : public base::RefCountedThreadSafe<JavaBridgeDispatcherHost>,
25 public content::RenderViewHostObserver { 28 public content::RenderViewHostObserver {
26 public: 29 public:
27 // We hold a weak pointer to the RenderViewhost. It must outlive this object. 30 // We hold a weak pointer to the RenderViewhost. It must outlive this object.
28 JavaBridgeDispatcherHost(RenderViewHost* render_view_host); 31 JavaBridgeDispatcherHost(content::RenderViewHost* render_view_host);
29 32
30 // Injects |object| into the main frame of the corresponding RenderView. A 33 // 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 34 // 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 35 // 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 36 // using |name|. The proxy object remains bound until the next time the
34 // window object is cleared after a call to RemoveNamedObject() or 37 // window object is cleared after a call to RemoveNamedObject() or
35 // AddNamedObject() with the same name. The proxy object proxies calls back 38 // AddNamedObject() with the same name. The proxy object proxies calls back
36 // to |object|, which is manipulated on the background thread. This class 39 // 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 40 // holds a reference to |object| for the time that the proxy object is bound
38 // to the window object. 41 // to the window object.
39 void AddNamedObject(const string16& name, NPObject* object); 42 void AddNamedObject(const string16& name, NPObject* object);
40 void RemoveNamedObject(const string16& name); 43 void RemoveNamedObject(const string16& name);
41 44
42 // RenderViewHostObserver overrides: 45 // RenderViewHostObserver overrides:
43 // The IPC macros require this to be public. 46 // The IPC macros require this to be public.
44 virtual bool Send(IPC::Message* msg) OVERRIDE; 47 virtual bool Send(IPC::Message* msg) OVERRIDE;
45 virtual void RenderViewHostDestroyed( 48 virtual void RenderViewHostDestroyed(
46 RenderViewHost* render_view_host) OVERRIDE; 49 content::RenderViewHost* render_view_host) OVERRIDE;
47 50
48 private: 51 private:
49 friend class base::RefCountedThreadSafe<JavaBridgeDispatcherHost>; 52 friend class base::RefCountedThreadSafe<JavaBridgeDispatcherHost>;
50 virtual ~JavaBridgeDispatcherHost(); 53 virtual ~JavaBridgeDispatcherHost();
51 54
52 // RenderViewHostObserver override: 55 // RenderViewHostObserver override:
53 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 56 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
54 57
55 // Message handlers 58 // Message handlers
56 void OnGetChannelHandle(IPC::Message* reply_msg); 59 void OnGetChannelHandle(IPC::Message* reply_msg);
57 60
58 void GetChannelHandle(IPC::Message* reply_msg); 61 void GetChannelHandle(IPC::Message* reply_msg);
59 void CreateNPVariantParam(NPObject* object, NPVariant_Param* param); 62 void CreateNPVariantParam(NPObject* object, NPVariant_Param* param);
60 void CreateObjectStub(NPObject* object, int route_id); 63 void CreateObjectStub(NPObject* object, int route_id);
61 64
62 scoped_refptr<NPChannelBase> channel_; 65 scoped_refptr<NPChannelBase> channel_;
63 bool is_renderer_initialized_; 66 bool is_renderer_initialized_;
64 67
65 DISALLOW_COPY_AND_ASSIGN(JavaBridgeDispatcherHost); 68 DISALLOW_COPY_AND_ASSIGN(JavaBridgeDispatcherHost);
66 }; 69 };
67 70
68 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_H_ 71 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698