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

Side by Side Diff: ppapi/proxy/dispatcher.h

Issue 6334016: Refactor PPAPI proxy resource handling to maintain which host they came from,... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 | « ppapi/ppapi_tests.gypi ('k') | ppapi/proxy/dispatcher.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 PPAPI_PROXY_DISPATCHER_H_ 5 #ifndef PPAPI_PROXY_DISPATCHER_H_
6 #define PPAPI_PROXY_DISPATCHER_H_ 6 #define PPAPI_PROXY_DISPATCHER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 11 matching lines...) Expand all
22 22
23 class MessageLoop; 23 class MessageLoop;
24 struct PPB_Var_Deprecated; 24 struct PPB_Var_Deprecated;
25 25
26 namespace base { 26 namespace base {
27 class WaitableEvent; 27 class WaitableEvent;
28 } 28 }
29 29
30 namespace IPC { 30 namespace IPC {
31 class SyncChannel; 31 class SyncChannel;
32 class TestSink;
32 } 33 }
33 34
34 namespace pp { 35 namespace pp {
35 namespace proxy { 36 namespace proxy {
36 37
37 class InterfaceProxy; 38 class InterfaceProxy;
38 class VarSerializationRules; 39 class VarSerializationRules;
39 40
40 // An interface proxy can represent either end of a cross-process interface 41 // An interface proxy can represent either end of a cross-process interface
41 // call. The "source" side is where the call is invoked, and the "target" side 42 // call. The "source" side is where the call is invoked, and the "target" side
(...skipping 11 matching lines...) Expand all
53 // | 54 // |
54 class Dispatcher : public IPC::Channel::Listener, 55 class Dispatcher : public IPC::Channel::Listener,
55 public IPC::Message::Sender { 56 public IPC::Message::Sender {
56 public: 57 public:
57 typedef const void* (*GetInterfaceFunc)(const char*); 58 typedef const void* (*GetInterfaceFunc)(const char*);
58 typedef int32_t (*InitModuleFunc)(PP_Module, GetInterfaceFunc); 59 typedef int32_t (*InitModuleFunc)(PP_Module, GetInterfaceFunc);
59 typedef void (*ShutdownModuleFunc)(); 60 typedef void (*ShutdownModuleFunc)();
60 61
61 ~Dispatcher(); 62 ~Dispatcher();
62 63
64 // You must call this function before anything else. Returns true on success.
63 bool InitWithChannel(MessageLoop* ipc_message_loop, 65 bool InitWithChannel(MessageLoop* ipc_message_loop,
64 const IPC::ChannelHandle& channel_handle, 66 const IPC::ChannelHandle& channel_handle,
65 bool is_client, 67 bool is_client,
66 base::WaitableEvent* shutdown_event); 68 base::WaitableEvent* shutdown_event);
67 69
70 // Alternative to InitWithChannel() for unit tests that want to send all
71 // messages sent via this dispatcher to the given test sink. The test sink
72 // must outlive this class.
73 void InitWithTestSink(IPC::TestSink* test_sink);
74
68 // Returns true if the dispatcher is on the plugin side, or false if it's the 75 // Returns true if the dispatcher is on the plugin side, or false if it's the
69 // browser side. 76 // browser side.
70 virtual bool IsPlugin() const = 0; 77 virtual bool IsPlugin() const = 0;
71 78
72 VarSerializationRules* serialization_rules() const { 79 VarSerializationRules* serialization_rules() const {
73 return serialization_rules_.get(); 80 return serialization_rules_.get();
74 } 81 }
75 PP_Module pp_module() const { 82 PP_Module pp_module() const {
76 return pp_module_; 83 return pp_module_;
77 } 84 }
(...skipping 19 matching lines...) Expand all
97 // Called if the remote side is declaring to us which interfaces it supports 104 // Called if the remote side is declaring to us which interfaces it supports
98 // so we don't have to query for each one. We'll pre-create proxies for 105 // so we don't have to query for each one. We'll pre-create proxies for
99 // each of the given interfaces. 106 // each of the given interfaces.
100 107
101 // IPC::Message::Sender implementation. 108 // IPC::Message::Sender implementation.
102 virtual bool Send(IPC::Message* msg); 109 virtual bool Send(IPC::Message* msg);
103 110
104 // IPC::Channel::Listener implementation. 111 // IPC::Channel::Listener implementation.
105 virtual bool OnMessageReceived(const IPC::Message& msg); 112 virtual bool OnMessageReceived(const IPC::Message& msg);
106 113
114 // Will be NULL in some unit tests.
107 IPC::SyncChannel* channel() const { 115 IPC::SyncChannel* channel() const {
108 return channel_.get(); 116 return channel_.get();
109 } 117 }
110 118
111 CallbackTracker& callback_tracker() { 119 CallbackTracker& callback_tracker() {
112 return callback_tracker_; 120 return callback_tracker_;
113 } 121 }
114 122
115 protected: 123 protected:
116 Dispatcher(base::ProcessHandle remote_process_handle, 124 Dispatcher(base::ProcessHandle remote_process_handle,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // proxyable. 165 // proxyable.
158 bool SetupProxyForTargetInterface(const std::string& interface); 166 bool SetupProxyForTargetInterface(const std::string& interface);
159 167
160 bool IsInterfaceTrusted(const std::string& interface); 168 bool IsInterfaceTrusted(const std::string& interface);
161 169
162 // Set by the derived classed to indicate the module ID corresponding to 170 // Set by the derived classed to indicate the module ID corresponding to
163 // this dispatcher. 171 // this dispatcher.
164 PP_Module pp_module_; 172 PP_Module pp_module_;
165 173
166 base::ProcessHandle remote_process_handle_; // See getter above. 174 base::ProcessHandle remote_process_handle_; // See getter above.
175
176 // When we're unit testing, this will indicate the sink for the messages to
177 // be deposited so they can be inspected by the test. When non-NULL, this
178 // indicates that the channel should not be used.
179 IPC::TestSink* test_sink_;
180
181 // Will be null for some tests when there is a test_sink_.
167 scoped_ptr<IPC::SyncChannel> channel_; 182 scoped_ptr<IPC::SyncChannel> channel_;
168 183
169 bool disallow_trusted_interfaces_; 184 bool disallow_trusted_interfaces_;
170 185
171 GetInterfaceFunc local_get_interface_; 186 GetInterfaceFunc local_get_interface_;
172 187
173 ProxyMap proxies_; 188 ProxyMap proxies_;
174 InterfaceProxy* id_to_proxy_[INTERFACE_ID_COUNT]; 189 InterfaceProxy* id_to_proxy_[INTERFACE_ID_COUNT];
175 190
176 // True if the remote side has declared which interfaces it supports in 191 // True if the remote side has declared which interfaces it supports in
(...skipping 11 matching lines...) Expand all
188 203
189 scoped_ptr<VarSerializationRules> serialization_rules_; 204 scoped_ptr<VarSerializationRules> serialization_rules_;
190 205
191 DISALLOW_COPY_AND_ASSIGN(Dispatcher); 206 DISALLOW_COPY_AND_ASSIGN(Dispatcher);
192 }; 207 };
193 208
194 } // namespace proxy 209 } // namespace proxy
195 } // namespace pp 210 } // namespace pp
196 211
197 #endif // PPAPI_PROXY_DISPATCHER_H_ 212 #endif // PPAPI_PROXY_DISPATCHER_H_
OLDNEW
« no previous file with comments | « ppapi/ppapi_tests.gypi ('k') | ppapi/proxy/dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698