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

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

Issue 336313018: [Android] Move content/browser/{renderer_host => android}/java/* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated paths for unit tests, rebased Created 6 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_H_
7
8 #include <vector>
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/strings/string16.h"
12 #include "content/child/npapi/npobject_stub.h"
13
14 class RouteIDGenerator;
15 struct NPObject;
16
17 namespace IPC {
18 class Message;
19 }
20
21 namespace content {
22 class NPChannelBase;
23 class RenderFrameHost;
24 struct NPVariant_Param;
25
26 // This class handles injecting Java objects into a single RenderFrame. The Java
27 // object itself lives in the browser process on a background thread, while a
28 // proxy object is created in the renderer. An instance of this class exists
29 // for each RenderViewHost.
30 class JavaBridgeDispatcherHost
31 : public base::RefCountedThreadSafe<JavaBridgeDispatcherHost> {
32 public:
33 // We hold a weak pointer to the RenderFrameHost. It must outlive this object.
34 explicit JavaBridgeDispatcherHost(RenderFrameHost* render_frame_host);
35
36 // Injects |object| into the main frame of the corresponding RenderView. A
37 // proxy object is created in the renderer and when the main frame's window
38 // object is next cleared, this proxy object is bound to the window object
39 // using |name|. The proxy object remains bound until the next time the
40 // window object is cleared after a call to RemoveNamedObject() or
41 // AddNamedObject() with the same name. The proxy object proxies calls back
42 // to |object|, which is manipulated on the background thread. This class
43 // holds a reference to |object| for the time that the proxy object is bound
44 // to the window object.
45 void AddNamedObject(const base::string16& name, NPObject* object);
46 void RemoveNamedObject(const base::string16& name);
47
48 // Since this object is ref-counted, it might outlive render_frame_host.
49 void RenderFrameDeleted();
50
51 void OnGetChannelHandle(IPC::Message* reply_msg);
52 void Send(IPC::Message* msg);
53
54 private:
55 friend class base::RefCountedThreadSafe<JavaBridgeDispatcherHost>;
56 virtual ~JavaBridgeDispatcherHost();
57
58 void GetChannelHandle(IPC::Message* reply_msg);
59 void CreateNPVariantParam(NPObject* object, NPVariant_Param* param);
60 void CreateObjectStub(NPObject* object, int render_process_id, int route_id);
61
62 scoped_refptr<NPChannelBase> channel_;
63 RenderFrameHost* render_frame_host_;
64 std::vector<base::WeakPtr<NPObjectStub> > stubs_;
65
66 DISALLOW_COPY_AND_ASSIGN(JavaBridgeDispatcherHost);
67 };
68
69 } // namespace content
70
71 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698