OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 CHROME_PLUGIN_NPOBJECT_PROXY_H_ | 8 #ifndef CHROME_PLUGIN_NPOBJECT_PROXY_H_ |
9 #define CHROME_PLUGIN_NPOBJECT_PROXY_H_ | 9 #define CHROME_PLUGIN_NPOBJECT_PROXY_H_ |
10 | 10 |
11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
12 #include "chrome/common/ipc_channel.h" | 12 #include "chrome/common/ipc_channel.h" |
13 #include "third_party/npapi/bindings/npruntime.h" | 13 #include "third_party/npapi/bindings/npruntime.h" |
14 | 14 |
15 class PluginChannelBase; | 15 class PluginChannelBase; |
16 struct NPObject; | 16 struct NPObject; |
17 struct NPVariant_Param; | 17 struct NPVariant_Param; |
18 | 18 |
| 19 namespace base { |
| 20 class WaitableEvent; |
| 21 } |
| 22 |
19 // 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 |
20 // proxy calls to NPObjects across process boundaries. This happens both ways, | 24 // proxy calls to NPObjects across process boundaries. This happens both ways, |
21 // 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 |
22 // 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 |
23 // 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 |
24 // channel (specifically, a PluginChannelBase). The NPObjectStub on the other | 28 // channel (specifically, a PluginChannelBase). The NPObjectStub on the other |
25 // 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 |
26 // returns the marshalled result. | 30 // returns the marshalled result. |
27 class NPObjectProxy : public IPC::Channel::Listener, | 31 class NPObjectProxy : public IPC::Channel::Listener, |
28 public IPC::Message::Sender { | 32 public IPC::Message::Sender { |
29 public: | 33 public: |
30 ~NPObjectProxy(); | 34 ~NPObjectProxy(); |
31 | 35 |
| 36 // modal_dialog_event_ is must be valid for the lifetime of the NPObjectProxy. |
32 static NPObject* Create(PluginChannelBase* channel, | 37 static NPObject* Create(PluginChannelBase* channel, |
33 int route_id, | 38 int route_id, |
34 void* npobject_ptr, | 39 void* npobject_ptr, |
35 HANDLE modal_dialog_event); | 40 base::WaitableEvent* modal_dialog_event); |
36 | 41 |
37 // IPC::Message::Sender implementation: | 42 // IPC::Message::Sender implementation: |
38 bool Send(IPC::Message* msg); | 43 bool Send(IPC::Message* msg); |
39 int route_id() { return route_id_; } | 44 int route_id() { return route_id_; } |
40 PluginChannelBase* channel() { return channel_; } | 45 PluginChannelBase* channel() { return channel_; } |
41 | 46 |
42 // Returns the real NPObject's pointer (obviously only valid in the other | 47 // Returns the real NPObject's pointer (obviously only valid in the other |
43 // process). | 48 // process). |
44 void* npobject_ptr() { return npobject_ptr_; } | 49 void* npobject_ptr() { return npobject_ptr_; } |
45 | 50 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 uint32_t arg_count, | 91 uint32_t arg_count, |
87 NPVariant *result); | 92 NPVariant *result); |
88 | 93 |
89 static NPObjectProxy* GetProxy(NPObject* object); | 94 static NPObjectProxy* GetProxy(NPObject* object); |
90 static const NPClass* npclass() { return &npclass_proxy_; } | 95 static const NPClass* npclass() { return &npclass_proxy_; } |
91 | 96 |
92 private: | 97 private: |
93 NPObjectProxy(PluginChannelBase* channel, | 98 NPObjectProxy(PluginChannelBase* channel, |
94 int route_id, | 99 int route_id, |
95 void* npobject_ptr, | 100 void* npobject_ptr, |
96 HANDLE modal_dialog_event); | 101 base::WaitableEvent* modal_dialog_event); |
97 | 102 |
98 // IPC::Channel::Listener implementation: | 103 // IPC::Channel::Listener implementation: |
99 void OnMessageReceived(const IPC::Message& msg); | 104 void OnMessageReceived(const IPC::Message& msg); |
100 void OnChannelError(); | 105 void OnChannelError(); |
101 | 106 |
102 static NPObject* NPAllocate(NPP, NPClass*); | 107 static NPObject* NPAllocate(NPP, NPClass*); |
103 static void NPDeallocate(NPObject* npObj); | 108 static void NPDeallocate(NPObject* npObj); |
104 | 109 |
105 // This function is only caled on NPObjects from the plugin. | 110 // This function is only caled on NPObjects from the plugin. |
106 static void NPPInvalidate(NPObject *obj); | 111 static void NPPInvalidate(NPObject *obj); |
107 static NPClass npclass_proxy_; | 112 static NPClass npclass_proxy_; |
108 | 113 |
109 int route_id_; | 114 int route_id_; |
110 void* npobject_ptr_; | 115 void* npobject_ptr_; |
111 scoped_refptr<PluginChannelBase> channel_; | 116 scoped_refptr<PluginChannelBase> channel_; |
112 HANDLE modal_dialog_event_; | 117 base::WaitableEvent* modal_dialog_event_; |
113 }; | 118 }; |
114 | 119 |
115 #endif // CHROME_PLUGIN_NPOBJECT_PROXY_H_ | 120 #endif // CHROME_PLUGIN_NPOBJECT_PROXY_H_ |
OLD | NEW |