OLD | NEW |
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 #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> |
(...skipping 30 matching lines...) Expand all Loading... |
41 // | | 41 // | |
42 // | | 42 // | |
43 // "Target" | "Source" | 43 // "Target" | "Source" |
44 // InterfaceProxy <---------------------- InterfaceProxy | 44 // InterfaceProxy <---------------------- InterfaceProxy |
45 // | | 45 // | |
46 class Dispatcher : public ProxyChannel { | 46 class Dispatcher : public ProxyChannel { |
47 public: | 47 public: |
48 typedef const void* (*GetInterfaceFunc)(const char*); | 48 typedef const void* (*GetInterfaceFunc)(const char*); |
49 typedef int32_t (*InitModuleFunc)(PP_Module, GetInterfaceFunc); | 49 typedef int32_t (*InitModuleFunc)(PP_Module, GetInterfaceFunc); |
50 | 50 |
51 class Delegate : public ProxyChannel::Delegate { | |
52 public: | |
53 // Returns the set used for globally uniquifying PP_Instances. This same | |
54 // set must be returned for all channels. This is required only for the | |
55 // plugin side, for the host side, the return value may be NULL. | |
56 // | |
57 // DEREFERENCE ONLY ON THE I/O THREAD. | |
58 virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet() = 0; | |
59 | |
60 // Returns the WebKit forwarding object used to make calls into WebKit. | |
61 // Necessary only on the plugin side. The host side can return NULL. | |
62 virtual ppapi::WebKitForwarding* GetWebKitForwarding() = 0; | |
63 | |
64 // Posts the given task to the WebKit thread associated with this plugin | |
65 // process. For host processes, this will not be called and can do | |
66 // nothing. The WebKit thread should be lazily created if it does not | |
67 // exist yet. | |
68 virtual void PostToWebKitThread(const tracked_objects::Location& from_here, | |
69 const base::Closure& task) = 0; | |
70 }; | |
71 | |
72 virtual ~Dispatcher(); | 51 virtual ~Dispatcher(); |
73 | 52 |
74 // Returns true if the dispatcher is on the plugin side, or false if it's the | 53 // Returns true if the dispatcher is on the plugin side, or false if it's the |
75 // browser side. | 54 // browser side. |
76 virtual bool IsPlugin() const = 0; | 55 virtual bool IsPlugin() const = 0; |
77 | 56 |
78 VarSerializationRules* serialization_rules() const { | 57 VarSerializationRules* serialization_rules() const { |
79 return serialization_rules_.get(); | 58 return serialization_rules_.get(); |
80 } | 59 } |
81 | 60 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 InterfaceID id); | 93 InterfaceID id); |
115 static const InterfaceProxy::Info* GetPPPInterfaceInfo( | 94 static const InterfaceProxy::Info* GetPPPInterfaceInfo( |
116 const std::string& name); | 95 const std::string& name); |
117 static const InterfaceProxy::Info* GetPPPInterfaceInfo( | 96 static const InterfaceProxy::Info* GetPPPInterfaceInfo( |
118 InterfaceID id); | 97 InterfaceID id); |
119 | 98 |
120 protected: | 99 protected: |
121 Dispatcher(base::ProcessHandle remote_process_handle, | 100 Dispatcher(base::ProcessHandle remote_process_handle, |
122 GetInterfaceFunc local_get_interface); | 101 GetInterfaceFunc local_get_interface); |
123 | 102 |
124 void SetDelegate(Delegate* delegate); | |
125 | |
126 // Setter for the derived classes to set the appropriate var serialization. | 103 // Setter for the derived classes to set the appropriate var serialization. |
127 // Takes ownership of the given pointer, which must be on the heap. | 104 // Takes ownership of the given pointer, which must be on the heap. |
128 void SetSerializationRules(VarSerializationRules* var_serialization_rules); | 105 void SetSerializationRules(VarSerializationRules* var_serialization_rules); |
129 | 106 |
130 bool disallow_trusted_interfaces() const { | 107 bool disallow_trusted_interfaces() const { |
131 return disallow_trusted_interfaces_; | 108 return disallow_trusted_interfaces_; |
132 } | 109 } |
133 | 110 |
134 Delegate* dispatcher_delegate_; | |
135 | |
136 private: | 111 private: |
137 bool disallow_trusted_interfaces_; | 112 bool disallow_trusted_interfaces_; |
138 | 113 |
139 GetInterfaceFunc local_get_interface_; | 114 GetInterfaceFunc local_get_interface_; |
140 | 115 |
141 CallbackTracker callback_tracker_; | 116 CallbackTracker callback_tracker_; |
142 | 117 |
143 scoped_ptr<VarSerializationRules> serialization_rules_; | 118 scoped_ptr<VarSerializationRules> serialization_rules_; |
144 | 119 |
145 DISALLOW_COPY_AND_ASSIGN(Dispatcher); | 120 DISALLOW_COPY_AND_ASSIGN(Dispatcher); |
146 }; | 121 }; |
147 | 122 |
148 } // namespace proxy | 123 } // namespace proxy |
149 } // namespace pp | 124 } // namespace pp |
150 | 125 |
151 #endif // PPAPI_PROXY_DISPATCHER_H_ | 126 #endif // PPAPI_PROXY_DISPATCHER_H_ |
OLD | NEW |