| OLD | NEW |
| 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 <set> |
| 9 #include <string> | 10 #include <string> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/linked_ptr.h" | 13 #include "base/linked_ptr.h" |
| 13 #include "base/process.h" | 14 #include "base/process.h" |
| 14 #include "base/scoped_ptr.h" | 15 #include "base/scoped_ptr.h" |
| 15 #include "ipc/ipc_channel.h" | 16 #include "ipc/ipc_channel.h" |
| 16 #include "ipc/ipc_channel_handle.h" | 17 #include "ipc/ipc_channel_handle.h" |
| 17 #include "ipc/ipc_message.h" | 18 #include "ipc/ipc_message.h" |
| 18 #include "ipc/ipc_platform_file.h" | 19 #include "ipc/ipc_platform_file.h" |
| 20 #include "ppapi/c/pp_instance.h" |
| 19 #include "ppapi/c/pp_module.h" | 21 #include "ppapi/c/pp_module.h" |
| 20 #include "ppapi/proxy/callback_tracker.h" | 22 #include "ppapi/proxy/callback_tracker.h" |
| 21 #include "ppapi/proxy/interface_id.h" | 23 #include "ppapi/proxy/interface_id.h" |
| 22 #include "ppapi/proxy/interface_proxy.h" | 24 #include "ppapi/proxy/interface_proxy.h" |
| 23 #include "ppapi/proxy/plugin_var_tracker.h" | 25 #include "ppapi/proxy/plugin_var_tracker.h" |
| 24 | 26 |
| 25 class MessageLoop; | 27 class MessageLoop; |
| 26 struct PPB_Var_Deprecated; | 28 struct PPB_Var_Deprecated; |
| 27 | 29 |
| 28 namespace base { | 30 namespace base { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 53 // "Target" | "Source" | 55 // "Target" | "Source" |
| 54 // InterfaceProxy <---------------------- InterfaceProxy | 56 // InterfaceProxy <---------------------- InterfaceProxy |
| 55 // | | 57 // | |
| 56 class Dispatcher : public IPC::Channel::Listener, | 58 class Dispatcher : public IPC::Channel::Listener, |
| 57 public IPC::Message::Sender { | 59 public IPC::Message::Sender { |
| 58 public: | 60 public: |
| 59 typedef const void* (*GetInterfaceFunc)(const char*); | 61 typedef const void* (*GetInterfaceFunc)(const char*); |
| 60 typedef int32_t (*InitModuleFunc)(PP_Module, GetInterfaceFunc); | 62 typedef int32_t (*InitModuleFunc)(PP_Module, GetInterfaceFunc); |
| 61 typedef void (*ShutdownModuleFunc)(); | 63 typedef void (*ShutdownModuleFunc)(); |
| 62 | 64 |
| 65 class Delegate { |
| 66 public: |
| 67 // Returns the dedicated message loop for processing IPC requests. |
| 68 virtual MessageLoop* GetIPCMessageLoop() = 0; |
| 69 |
| 70 // Returns the event object that becomes signalled when the main thread's |
| 71 // message loop exits. |
| 72 virtual base::WaitableEvent* GetShutdownEvent() = 0; |
| 73 |
| 74 // Returns the set used for globally uniquifying PP_Instances. This same |
| 75 // set must be returned for all channels. This is required only for the |
| 76 // plugin side, for the host side, the return value may be NULL. |
| 77 // |
| 78 // DEREFERENCE ONLY ON THE I/O THREAD. |
| 79 virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet() = 0; |
| 80 }; |
| 81 |
| 63 virtual ~Dispatcher(); | 82 virtual ~Dispatcher(); |
| 64 | 83 |
| 65 // You must call this function before anything else. Returns true on success. | 84 // You must call this function before anything else. Returns true on success. |
| 66 bool InitWithChannel(MessageLoop* ipc_message_loop, | 85 // The delegate pointer must outlive this class, ownership is not |
| 67 const IPC::ChannelHandle& channel_handle, | 86 // transferred. |
| 68 bool is_client, | 87 virtual bool InitWithChannel(Delegate* delegate, |
| 69 base::WaitableEvent* shutdown_event); | 88 const IPC::ChannelHandle& channel_handle, |
| 89 bool is_client); |
| 70 | 90 |
| 71 // Alternative to InitWithChannel() for unit tests that want to send all | 91 // Alternative to InitWithChannel() for unit tests that want to send all |
| 72 // messages sent via this dispatcher to the given test sink. The test sink | 92 // messages sent via this dispatcher to the given test sink. The test sink |
| 73 // must outlive this class. | 93 // must outlive this class. |
| 74 void InitWithTestSink(IPC::TestSink* test_sink); | 94 void InitWithTestSink(IPC::TestSink* test_sink); |
| 75 | 95 |
| 76 // Returns true if the dispatcher is on the plugin side, or false if it's the | 96 // Returns true if the dispatcher is on the plugin side, or false if it's the |
| 77 // browser side. | 97 // browser side. |
| 78 virtual bool IsPlugin() const = 0; | 98 virtual bool IsPlugin() const = 0; |
| 79 | 99 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 GetInterfaceFunc local_get_interface); | 150 GetInterfaceFunc local_get_interface); |
| 131 | 151 |
| 132 // Setter for the derived classes to set the appropriate var serialization. | 152 // Setter for the derived classes to set the appropriate var serialization. |
| 133 // Takes ownership of the given pointer, which must be on the heap. | 153 // Takes ownership of the given pointer, which must be on the heap. |
| 134 void SetSerializationRules(VarSerializationRules* var_serialization_rules); | 154 void SetSerializationRules(VarSerializationRules* var_serialization_rules); |
| 135 | 155 |
| 136 bool disallow_trusted_interfaces() const { | 156 bool disallow_trusted_interfaces() const { |
| 137 return disallow_trusted_interfaces_; | 157 return disallow_trusted_interfaces_; |
| 138 } | 158 } |
| 139 | 159 |
| 160 Delegate* delegate() { return delegate_; } |
| 161 |
| 140 private: | 162 private: |
| 163 // Non-owning pointer. Guaranteed non-NULL after init is called. |
| 164 Delegate* delegate_; |
| 165 |
| 141 base::ProcessHandle remote_process_handle_; // See getter above. | 166 base::ProcessHandle remote_process_handle_; // See getter above. |
| 142 | 167 |
| 143 // When we're unit testing, this will indicate the sink for the messages to | 168 // When we're unit testing, this will indicate the sink for the messages to |
| 144 // be deposited so they can be inspected by the test. When non-NULL, this | 169 // be deposited so they can be inspected by the test. When non-NULL, this |
| 145 // indicates that the channel should not be used. | 170 // indicates that the channel should not be used. |
| 146 IPC::TestSink* test_sink_; | 171 IPC::TestSink* test_sink_; |
| 147 | 172 |
| 148 // Will be null for some tests when there is a test_sink_, and if the | 173 // Will be null for some tests when there is a test_sink_, and if the |
| 149 // remote side has crashed. | 174 // remote side has crashed. |
| 150 scoped_ptr<IPC::SyncChannel> channel_; | 175 scoped_ptr<IPC::SyncChannel> channel_; |
| 151 | 176 |
| 152 bool disallow_trusted_interfaces_; | 177 bool disallow_trusted_interfaces_; |
| 153 | 178 |
| 154 GetInterfaceFunc local_get_interface_; | 179 GetInterfaceFunc local_get_interface_; |
| 155 | 180 |
| 156 CallbackTracker callback_tracker_; | 181 CallbackTracker callback_tracker_; |
| 157 | 182 |
| 158 scoped_ptr<VarSerializationRules> serialization_rules_; | 183 scoped_ptr<VarSerializationRules> serialization_rules_; |
| 159 | 184 |
| 160 DISALLOW_COPY_AND_ASSIGN(Dispatcher); | 185 DISALLOW_COPY_AND_ASSIGN(Dispatcher); |
| 161 }; | 186 }; |
| 162 | 187 |
| 163 } // namespace proxy | 188 } // namespace proxy |
| 164 } // namespace pp | 189 } // namespace pp |
| 165 | 190 |
| 166 #endif // PPAPI_PROXY_DISPATCHER_H_ | 191 #endif // PPAPI_PROXY_DISPATCHER_H_ |
| OLD | NEW |