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 #include <map> | 5 #include <map> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 virtual void SetUpHarnessWithChannel(const IPC::ChannelHandle& channel_handle, | 113 virtual void SetUpHarnessWithChannel(const IPC::ChannelHandle& channel_handle, |
114 base::MessageLoopProxy* ipc_message_loop, | 114 base::MessageLoopProxy* ipc_message_loop, |
115 base::WaitableEvent* shutdown_event, | 115 base::WaitableEvent* shutdown_event, |
116 bool is_client); | 116 bool is_client); |
117 virtual void TearDownHarness(); | 117 virtual void TearDownHarness(); |
118 | 118 |
119 class PluginDelegateMock : public PluginDispatcher::PluginDelegate, | 119 class PluginDelegateMock : public PluginDispatcher::PluginDelegate, |
120 public PluginProxyDelegate { | 120 public PluginProxyDelegate { |
121 public: | 121 public: |
122 PluginDelegateMock() : ipc_message_loop_(NULL), shutdown_event_() {} | 122 PluginDelegateMock() : ipc_message_loop_(NULL), shutdown_event_() {} |
123 virtual ~PluginDelegateMock() {} | 123 ~PluginDelegateMock() override {} |
124 | 124 |
125 void Init(base::MessageLoopProxy* ipc_message_loop, | 125 void Init(base::MessageLoopProxy* ipc_message_loop, |
126 base::WaitableEvent* shutdown_event) { | 126 base::WaitableEvent* shutdown_event) { |
127 ipc_message_loop_ = ipc_message_loop; | 127 ipc_message_loop_ = ipc_message_loop; |
128 shutdown_event_ = shutdown_event; | 128 shutdown_event_ = shutdown_event; |
129 } | 129 } |
130 | 130 |
131 void set_browser_sender(IPC::Sender* browser_sender) { | 131 void set_browser_sender(IPC::Sender* browser_sender) { |
132 browser_sender_ = browser_sender; | 132 browser_sender_ = browser_sender; |
133 } | 133 } |
134 | 134 |
135 // ProxyChannel::Delegate implementation. | 135 // ProxyChannel::Delegate implementation. |
136 virtual base::MessageLoopProxy* GetIPCMessageLoop() override; | 136 base::MessageLoopProxy* GetIPCMessageLoop() override; |
137 virtual base::WaitableEvent* GetShutdownEvent() override; | 137 base::WaitableEvent* GetShutdownEvent() override; |
138 virtual IPC::PlatformFileForTransit ShareHandleWithRemote( | 138 IPC::PlatformFileForTransit ShareHandleWithRemote( |
139 base::PlatformFile handle, | 139 base::PlatformFile handle, |
140 base::ProcessId remote_pid, | 140 base::ProcessId remote_pid, |
141 bool should_close_source) override; | 141 bool should_close_source) override; |
142 | 142 |
143 // PluginDispatcher::PluginDelegate implementation. | 143 // PluginDispatcher::PluginDelegate implementation. |
144 virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet() override; | 144 std::set<PP_Instance>* GetGloballySeenInstanceIDSet() override; |
145 virtual uint32 Register(PluginDispatcher* plugin_dispatcher) override; | 145 uint32 Register(PluginDispatcher* plugin_dispatcher) override; |
146 virtual void Unregister(uint32 plugin_dispatcher_id) override; | 146 void Unregister(uint32 plugin_dispatcher_id) override; |
147 | 147 |
148 // PluginProxyDelegate implementation. | 148 // PluginProxyDelegate implementation. |
149 virtual IPC::Sender* GetBrowserSender() override; | 149 IPC::Sender* GetBrowserSender() override; |
150 virtual std::string GetUILanguage() override; | 150 std::string GetUILanguage() override; |
151 virtual void PreCacheFont(const void* logfontw) override; | 151 void PreCacheFont(const void* logfontw) override; |
152 virtual void SetActiveURL(const std::string& url) override; | 152 void SetActiveURL(const std::string& url) override; |
153 virtual PP_Resource CreateBrowserFont( | 153 PP_Resource CreateBrowserFont( |
154 Connection connection, | 154 Connection connection, |
155 PP_Instance instance, | 155 PP_Instance instance, |
156 const PP_BrowserFont_Trusted_Description& desc, | 156 const PP_BrowserFont_Trusted_Description& desc, |
157 const Preferences& prefs) override; | 157 const Preferences& prefs) override; |
158 | 158 |
159 private: | 159 private: |
160 base::MessageLoopProxy* ipc_message_loop_; // Weak | 160 base::MessageLoopProxy* ipc_message_loop_; // Weak |
161 base::WaitableEvent* shutdown_event_; // Weak | 161 base::WaitableEvent* shutdown_event_; // Weak |
162 std::set<PP_Instance> instance_id_set_; | 162 std::set<PP_Instance> instance_id_set_; |
163 IPC::Sender* browser_sender_; | 163 IPC::Sender* browser_sender_; |
(...skipping 27 matching lines...) Expand all Loading... |
191 // This class provides support for multi-thread testing. A secondary thread is | 191 // This class provides support for multi-thread testing. A secondary thread is |
192 // created with a Pepper message loop. | 192 // created with a Pepper message loop. |
193 // Subclasses need to implement the two SetUpTestOn*Thread() methods to do the | 193 // Subclasses need to implement the two SetUpTestOn*Thread() methods to do the |
194 // actual testing work; and call both PostQuitFor*Thread() when testing is | 194 // actual testing work; and call both PostQuitFor*Thread() when testing is |
195 // done. | 195 // done. |
196 class PluginProxyMultiThreadTest | 196 class PluginProxyMultiThreadTest |
197 : public PluginProxyTest, | 197 : public PluginProxyTest, |
198 public base::DelegateSimpleThread::Delegate { | 198 public base::DelegateSimpleThread::Delegate { |
199 public: | 199 public: |
200 PluginProxyMultiThreadTest(); | 200 PluginProxyMultiThreadTest(); |
201 virtual ~PluginProxyMultiThreadTest(); | 201 ~PluginProxyMultiThreadTest() override; |
202 | 202 |
203 // Called before the secondary thread is started, but after all the member | 203 // Called before the secondary thread is started, but after all the member |
204 // variables, including |secondary_thread_| and | 204 // variables, including |secondary_thread_| and |
205 // |secondary_thread_message_loop_|, are initialized. | 205 // |secondary_thread_message_loop_|, are initialized. |
206 virtual void SetUpTestOnMainThread() = 0; | 206 virtual void SetUpTestOnMainThread() = 0; |
207 | 207 |
208 virtual void SetUpTestOnSecondaryThread() = 0; | 208 virtual void SetUpTestOnSecondaryThread() = 0; |
209 | 209 |
210 // TEST_F() should call this method. | 210 // TEST_F() should call this method. |
211 void RunTest(); | 211 void RunTest(); |
212 | 212 |
213 enum ThreadType { | 213 enum ThreadType { |
214 MAIN_THREAD, | 214 MAIN_THREAD, |
215 SECONDARY_THREAD | 215 SECONDARY_THREAD |
216 }; | 216 }; |
217 void CheckOnThread(ThreadType thread_type); | 217 void CheckOnThread(ThreadType thread_type); |
218 | 218 |
219 // These can be called on any thread. | 219 // These can be called on any thread. |
220 void PostQuitForMainThread(); | 220 void PostQuitForMainThread(); |
221 void PostQuitForSecondaryThread(); | 221 void PostQuitForSecondaryThread(); |
222 | 222 |
223 protected: | 223 protected: |
224 scoped_refptr<MessageLoopResource> secondary_thread_message_loop_; | 224 scoped_refptr<MessageLoopResource> secondary_thread_message_loop_; |
225 scoped_refptr<base::MessageLoopProxy> main_thread_message_loop_proxy_; | 225 scoped_refptr<base::MessageLoopProxy> main_thread_message_loop_proxy_; |
226 | 226 |
227 private: | 227 private: |
228 // base::DelegateSimpleThread::Delegate implementation. | 228 // base::DelegateSimpleThread::Delegate implementation. |
229 virtual void Run() override; | 229 void Run() override; |
230 | 230 |
231 void QuitNestedLoop(); | 231 void QuitNestedLoop(); |
232 | 232 |
233 static void InternalSetUpTestOnSecondaryThread(void* user_data, | 233 static void InternalSetUpTestOnSecondaryThread(void* user_data, |
234 int32_t result); | 234 int32_t result); |
235 | 235 |
236 scoped_ptr<base::DelegateSimpleThread> secondary_thread_; | 236 scoped_ptr<base::DelegateSimpleThread> secondary_thread_; |
237 scoped_ptr<base::RunLoop> nested_main_thread_message_loop_; | 237 scoped_ptr<base::RunLoop> nested_main_thread_message_loop_; |
238 }; | 238 }; |
239 | 239 |
(...skipping 17 matching lines...) Expand all Loading... |
257 virtual void SetUpHarnessWithChannel(const IPC::ChannelHandle& channel_handle, | 257 virtual void SetUpHarnessWithChannel(const IPC::ChannelHandle& channel_handle, |
258 base::MessageLoopProxy* ipc_message_loop, | 258 base::MessageLoopProxy* ipc_message_loop, |
259 base::WaitableEvent* shutdown_event, | 259 base::WaitableEvent* shutdown_event, |
260 bool is_client); | 260 bool is_client); |
261 virtual void TearDownHarness(); | 261 virtual void TearDownHarness(); |
262 | 262 |
263 class DelegateMock : public ProxyChannel::Delegate { | 263 class DelegateMock : public ProxyChannel::Delegate { |
264 public: | 264 public: |
265 DelegateMock() : ipc_message_loop_(NULL), shutdown_event_(NULL) { | 265 DelegateMock() : ipc_message_loop_(NULL), shutdown_event_(NULL) { |
266 } | 266 } |
267 virtual ~DelegateMock() {} | 267 ~DelegateMock() override {} |
268 | 268 |
269 void Init(base::MessageLoopProxy* ipc_message_loop, | 269 void Init(base::MessageLoopProxy* ipc_message_loop, |
270 base::WaitableEvent* shutdown_event) { | 270 base::WaitableEvent* shutdown_event) { |
271 ipc_message_loop_ = ipc_message_loop; | 271 ipc_message_loop_ = ipc_message_loop; |
272 shutdown_event_ = shutdown_event; | 272 shutdown_event_ = shutdown_event; |
273 } | 273 } |
274 | 274 |
275 // ProxyChannel::Delegate implementation. | 275 // ProxyChannel::Delegate implementation. |
276 virtual base::MessageLoopProxy* GetIPCMessageLoop(); | 276 base::MessageLoopProxy* GetIPCMessageLoop() override; |
277 virtual base::WaitableEvent* GetShutdownEvent(); | 277 base::WaitableEvent* GetShutdownEvent() override; |
278 virtual IPC::PlatformFileForTransit ShareHandleWithRemote( | 278 IPC::PlatformFileForTransit ShareHandleWithRemote( |
279 base::PlatformFile handle, | 279 base::PlatformFile handle, |
280 base::ProcessId remote_pid, | 280 base::ProcessId remote_pid, |
281 bool should_close_source) override; | 281 bool should_close_source) override; |
282 | 282 |
283 private: | 283 private: |
284 base::MessageLoopProxy* ipc_message_loop_; // Weak | 284 base::MessageLoopProxy* ipc_message_loop_; // Weak |
285 base::WaitableEvent* shutdown_event_; // Weak | 285 base::WaitableEvent* shutdown_event_; // Weak |
286 | 286 |
287 DISALLOW_COPY_AND_ASSIGN(DelegateMock); | 287 DISALLOW_COPY_AND_ASSIGN(DelegateMock); |
288 }; | 288 }; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 // EXPECT_VAR_IS_STRING("foo", my_var); | 365 // EXPECT_VAR_IS_STRING("foo", my_var); |
366 #define EXPECT_VAR_IS_STRING(str, var) { \ | 366 #define EXPECT_VAR_IS_STRING(str, var) { \ |
367 StringVar* sv = StringVar::FromPPVar(var); \ | 367 StringVar* sv = StringVar::FromPPVar(var); \ |
368 EXPECT_TRUE(sv); \ | 368 EXPECT_TRUE(sv); \ |
369 if (sv) \ | 369 if (sv) \ |
370 EXPECT_EQ(str, sv->value()); \ | 370 EXPECT_EQ(str, sv->value()); \ |
371 } | 371 } |
372 | 372 |
373 } // namespace proxy | 373 } // namespace proxy |
374 } // namespace ppapi | 374 } // namespace ppapi |
OLD | NEW |