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

Side by Side Diff: content/common/npobject_proxy.h

Issue 10662005: Use IPC::Sender and IPC::Listener in content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
« no previous file with comments | « content/common/npobject_base.h ('k') | content/common/npobject_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // A proxy for NPObject that sends all calls to the object to an NPObjectStub 5 // A proxy for NPObject that sends all calls to the object to an NPObjectStub
6 // running in a different process. 6 // running in a different process.
7 7
8 #ifndef CONTENT_COMMON_NPOBJECT_PROXY_H_ 8 #ifndef CONTENT_COMMON_NPOBJECT_PROXY_H_
9 #define CONTENT_COMMON_NPOBJECT_PROXY_H_ 9 #define CONTENT_COMMON_NPOBJECT_PROXY_H_
10 #pragma once 10 #pragma once
11 11
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "content/common/npobject_base.h" 13 #include "content/common/npobject_base.h"
14 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
15 #include "ipc/ipc_channel.h" 15 #include "ipc/ipc_listener.h"
16 #include "ipc/ipc_sender.h"
16 #include "third_party/npapi/bindings/npruntime.h" 17 #include "third_party/npapi/bindings/npruntime.h"
17 #include "ui/gfx/native_widget_types.h" 18 #include "ui/gfx/native_widget_types.h"
18 19
19 class NPChannelBase; 20 class NPChannelBase;
20 struct NPObject; 21 struct NPObject;
21 22
22 // When running a plugin in a different process from the renderer, we need to 23 // When running a plugin in a different process from the renderer, we need to
23 // proxy calls to NPObjects across process boundaries. This happens both ways, 24 // proxy calls to NPObjects across process boundaries. This happens both ways,
24 // as a plugin can get an NPObject for the window, and a page can get an 25 // as a plugin can get an NPObject for the window, and a page can get an
25 // NPObject for the plugin. In the process that interacts with the NPobject we 26 // NPObject for the plugin. In the process that interacts with the NPobject we
26 // give it an NPObjectProxy instead. All calls to it are sent across an IPC 27 // give it an NPObjectProxy instead. All calls to it are sent across an IPC
27 // channel (specifically, a NPChannelBase). The NPObjectStub on the other 28 // channel (specifically, a NPChannelBase). The NPObjectStub on the other
28 // side translates the IPC messages into calls to the actual NPObject, and 29 // side translates the IPC messages into calls to the actual NPObject, and
29 // returns the marshalled result. 30 // returns the marshalled result.
30 class NPObjectProxy : public IPC::Channel::Listener, 31 class NPObjectProxy : public IPC::Listener,
31 public IPC::Message::Sender, 32 public IPC::Sender,
32 public NPObjectBase { 33 public NPObjectBase {
33 public: 34 public:
34 virtual ~NPObjectProxy(); 35 virtual ~NPObjectProxy();
35 36
36 static NPObject* Create(NPChannelBase* channel, 37 static NPObject* Create(NPChannelBase* channel,
37 int route_id, 38 int route_id,
38 gfx::NativeViewId containing_window, 39 gfx::NativeViewId containing_window,
39 const GURL& page_url); 40 const GURL& page_url);
40 41
41 // IPC::Message::Sender implementation: 42 // IPC::Sender implementation:
42 virtual bool Send(IPC::Message* msg) OVERRIDE; 43 virtual bool Send(IPC::Message* msg) OVERRIDE;
43 int route_id() { return route_id_; } 44 int route_id() { return route_id_; }
44 NPChannelBase* channel() { return channel_; } 45 NPChannelBase* channel() { return channel_; }
45 46
46 // The next 9 functions are called on NPObjects from the plugin and browser. 47 // The next 9 functions are called on NPObjects from the plugin and browser.
47 static bool NPHasMethod(NPObject *obj, 48 static bool NPHasMethod(NPObject *obj,
48 NPIdentifier name); 49 NPIdentifier name);
49 static bool NPInvoke(NPObject *obj, 50 static bool NPInvoke(NPObject *obj,
50 NPIdentifier name, 51 NPIdentifier name,
51 const NPVariant *args, 52 const NPVariant *args,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 const NPVariant *args, 87 const NPVariant *args,
87 uint32_t arg_count, 88 uint32_t arg_count,
88 NPVariant *result); 89 NPVariant *result);
89 90
90 static NPObjectProxy* GetProxy(NPObject* object); 91 static NPObjectProxy* GetProxy(NPObject* object);
91 static const NPClass* npclass() { return &npclass_proxy_; } 92 static const NPClass* npclass() { return &npclass_proxy_; }
92 93
93 // NPObjectBase implementation. 94 // NPObjectBase implementation.
94 virtual NPObject* GetUnderlyingNPObject() OVERRIDE; 95 virtual NPObject* GetUnderlyingNPObject() OVERRIDE;
95 96
96 virtual IPC::Channel::Listener* GetChannelListener() OVERRIDE; 97 virtual IPC::Listener* GetChannelListener() OVERRIDE;
97 98
98 private: 99 private:
99 NPObjectProxy(NPChannelBase* channel, 100 NPObjectProxy(NPChannelBase* channel,
100 int route_id, 101 int route_id,
101 gfx::NativeViewId containing_window, 102 gfx::NativeViewId containing_window,
102 const GURL& page_url); 103 const GURL& page_url);
103 104
104 // IPC::Channel::Listener implementation: 105 // IPC::Listener implementation:
105 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 106 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
106 virtual void OnChannelError() OVERRIDE; 107 virtual void OnChannelError() OVERRIDE;
107 108
108 static NPObject* NPAllocate(NPP, NPClass*); 109 static NPObject* NPAllocate(NPP, NPClass*);
109 static void NPDeallocate(NPObject* npObj); 110 static void NPDeallocate(NPObject* npObj);
110 111
111 // This function is only caled on NPObjects from the plugin. 112 // This function is only caled on NPObjects from the plugin.
112 static void NPPInvalidate(NPObject *obj); 113 static void NPPInvalidate(NPObject *obj);
113 static NPClass npclass_proxy_; 114 static NPClass npclass_proxy_;
114 115
115 scoped_refptr<NPChannelBase> channel_; 116 scoped_refptr<NPChannelBase> channel_;
116 int route_id_; 117 int route_id_;
117 gfx::NativeViewId containing_window_; 118 gfx::NativeViewId containing_window_;
118 119
119 // The url of the main frame hosting the plugin. 120 // The url of the main frame hosting the plugin.
120 GURL page_url_; 121 GURL page_url_;
121 }; 122 };
122 123
123 #endif // CONTENT_COMMON_NPOBJECT_PROXY_H_ 124 #endif // CONTENT_COMMON_NPOBJECT_PROXY_H_
OLDNEW
« no previous file with comments | « content/common/npobject_base.h ('k') | content/common/npobject_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698