OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/tracked_objects.h" | 14 #include "base/tracked_objects.h" |
15 #include "ipc/ipc_channel_proxy.h" | 15 #include "ipc/ipc_channel_proxy.h" |
16 #include "ppapi/c/pp_instance.h" | 16 #include "ppapi/c/pp_instance.h" |
17 #include "ppapi/c/pp_module.h" | 17 #include "ppapi/c/pp_module.h" |
| 18 #include "ppapi/c/ppp.h" |
18 #include "ppapi/proxy/proxy_channel.h" | 19 #include "ppapi/proxy/proxy_channel.h" |
19 #include "ppapi/proxy/interface_list.h" | 20 #include "ppapi/proxy/interface_list.h" |
20 #include "ppapi/proxy/interface_proxy.h" | 21 #include "ppapi/proxy/interface_proxy.h" |
21 #include "ppapi/proxy/plugin_var_tracker.h" | 22 #include "ppapi/proxy/plugin_var_tracker.h" |
22 #include "ppapi/shared_impl/api_id.h" | 23 #include "ppapi/shared_impl/api_id.h" |
23 | 24 |
24 namespace ppapi { | 25 namespace ppapi { |
25 | 26 |
26 namespace proxy { | 27 namespace proxy { |
27 | 28 |
28 class VarSerializationRules; | 29 class VarSerializationRules; |
29 | 30 |
30 // An interface proxy can represent either end of a cross-process interface | 31 // An interface proxy can represent either end of a cross-process interface |
31 // call. The "source" side is where the call is invoked, and the "target" side | 32 // call. The "source" side is where the call is invoked, and the "target" side |
32 // is where the call ends up being executed. | 33 // is where the call ends up being executed. |
33 // | 34 // |
34 // Plugin side | Browser side | 35 // Plugin side | Browser side |
35 // -------------------------------------|-------------------------------------- | 36 // -------------------------------------|-------------------------------------- |
36 // | | 37 // | |
37 // "Source" | "Target" | 38 // "Source" | "Target" |
38 // InterfaceProxy ----------------------> InterfaceProxy | 39 // InterfaceProxy ----------------------> InterfaceProxy |
39 // | | 40 // | |
40 // | | 41 // | |
41 // "Target" | "Source" | 42 // "Target" | "Source" |
42 // InterfaceProxy <---------------------- InterfaceProxy | 43 // InterfaceProxy <---------------------- InterfaceProxy |
43 // | | 44 // | |
44 class PPAPI_PROXY_EXPORT Dispatcher : public ProxyChannel { | 45 class PPAPI_PROXY_EXPORT Dispatcher : public ProxyChannel { |
45 public: | 46 public: |
46 typedef const void* (*GetInterfaceFunc)(const char*); | |
47 typedef int32_t (*InitModuleFunc)(PP_Module, GetInterfaceFunc); | |
48 | |
49 virtual ~Dispatcher(); | 47 virtual ~Dispatcher(); |
50 | 48 |
51 // Returns true if the dispatcher is on the plugin side, or false if it's the | 49 // Returns true if the dispatcher is on the plugin side, or false if it's the |
52 // browser side. | 50 // browser side. |
53 virtual bool IsPlugin() const = 0; | 51 virtual bool IsPlugin() const = 0; |
54 | 52 |
55 VarSerializationRules* serialization_rules() const { | 53 VarSerializationRules* serialization_rules() const { |
56 return serialization_rules_.get(); | 54 return serialization_rules_.get(); |
57 } | 55 } |
58 | 56 |
(...skipping 15 matching lines...) Expand all Loading... |
74 void AddIOThreadMessageFilter(IPC::ChannelProxy::MessageFilter* filter); | 72 void AddIOThreadMessageFilter(IPC::ChannelProxy::MessageFilter* filter); |
75 | 73 |
76 // TODO(brettw): What is this comment referring to? | 74 // TODO(brettw): What is this comment referring to? |
77 // Called if the remote side is declaring to us which interfaces it supports | 75 // Called if the remote side is declaring to us which interfaces it supports |
78 // so we don't have to query for each one. We'll pre-create proxies for | 76 // so we don't have to query for each one. We'll pre-create proxies for |
79 // each of the given interfaces. | 77 // each of the given interfaces. |
80 | 78 |
81 // IPC::Channel::Listener implementation. | 79 // IPC::Channel::Listener implementation. |
82 virtual bool OnMessageReceived(const IPC::Message& msg); | 80 virtual bool OnMessageReceived(const IPC::Message& msg); |
83 | 81 |
84 GetInterfaceFunc local_get_interface() const { return local_get_interface_; } | 82 PP_GetInterface_Func local_get_interface() const { |
| 83 return local_get_interface_; |
| 84 } |
85 | 85 |
86 protected: | 86 protected: |
87 Dispatcher(base::ProcessHandle remote_process_handle, | 87 Dispatcher(base::ProcessHandle remote_process_handle, |
88 GetInterfaceFunc local_get_interface); | 88 PP_GetInterface_Func local_get_interface); |
89 | 89 |
90 // Setter for the derived classes to set the appropriate var serialization. | 90 // Setter for the derived classes to set the appropriate var serialization. |
91 // Takes one reference of the given pointer, which must be on the heap. | 91 // Takes one reference of the given pointer, which must be on the heap. |
92 void SetSerializationRules(VarSerializationRules* var_serialization_rules); | 92 void SetSerializationRules(VarSerializationRules* var_serialization_rules); |
93 | 93 |
94 // Called when an invalid message is received from the remote site. The | 94 // Called when an invalid message is received from the remote site. The |
95 // default implementation does nothing, derived classes can override. | 95 // default implementation does nothing, derived classes can override. |
96 virtual void OnInvalidMessageReceived(); | 96 virtual void OnInvalidMessageReceived(); |
97 | 97 |
98 bool disallow_trusted_interfaces() const { | 98 bool disallow_trusted_interfaces() const { |
99 return disallow_trusted_interfaces_; | 99 return disallow_trusted_interfaces_; |
100 } | 100 } |
101 | 101 |
102 private: | 102 private: |
103 friend class HostDispatcherTest; | 103 friend class HostDispatcherTest; |
104 friend class PluginDispatcherTest; | 104 friend class PluginDispatcherTest; |
105 | 105 |
106 // Lists all lazily-created interface proxies. | 106 // Lists all lazily-created interface proxies. |
107 scoped_ptr<InterfaceProxy> proxies_[API_ID_COUNT]; | 107 scoped_ptr<InterfaceProxy> proxies_[API_ID_COUNT]; |
108 | 108 |
109 bool disallow_trusted_interfaces_; | 109 bool disallow_trusted_interfaces_; |
110 | 110 |
111 GetInterfaceFunc local_get_interface_; | 111 PP_GetInterface_Func local_get_interface_; |
112 | 112 |
113 scoped_refptr<VarSerializationRules> serialization_rules_; | 113 scoped_refptr<VarSerializationRules> serialization_rules_; |
114 | 114 |
115 DISALLOW_COPY_AND_ASSIGN(Dispatcher); | 115 DISALLOW_COPY_AND_ASSIGN(Dispatcher); |
116 }; | 116 }; |
117 | 117 |
118 } // namespace proxy | 118 } // namespace proxy |
119 } // namespace ppapi | 119 } // namespace ppapi |
120 | 120 |
121 #endif // PPAPI_PROXY_DISPATCHER_H_ | 121 #endif // PPAPI_PROXY_DISPATCHER_H_ |
OLD | NEW |