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 "ppapi/proxy/ppapi_proxy_test.h" | 5 #include "ppapi/proxy/ppapi_proxy_test.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // These must be first since the dispatcher set-up uses them. | 195 // These must be first since the dispatcher set-up uses them. |
196 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | 196 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
197 resource_tracker().DidCreateInstance(pp_instance()); | 197 resource_tracker().DidCreateInstance(pp_instance()); |
198 plugin_delegate_mock_.Init(ipc_message_loop, shutdown_event); | 198 plugin_delegate_mock_.Init(ipc_message_loop, shutdown_event); |
199 | 199 |
200 plugin_dispatcher_.reset(new PluginDispatcher( | 200 plugin_dispatcher_.reset(new PluginDispatcher( |
201 &MockGetInterface, | 201 &MockGetInterface, |
202 PpapiPermissions(), | 202 PpapiPermissions(), |
203 false)); | 203 false)); |
204 plugin_dispatcher_->InitPluginWithChannel(&plugin_delegate_mock_, | 204 plugin_dispatcher_->InitPluginWithChannel(&plugin_delegate_mock_, |
| 205 base::kNullProcessId, |
205 channel_handle, | 206 channel_handle, |
206 is_client); | 207 is_client); |
207 plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); | 208 plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); |
208 PluginGlobals::Get()->set_plugin_proxy_delegate(&plugin_delegate_mock_); | 209 PluginGlobals::Get()->set_plugin_proxy_delegate(&plugin_delegate_mock_); |
209 plugin_dispatcher_->DidCreateInstance(pp_instance()); | 210 plugin_dispatcher_->DidCreateInstance(pp_instance()); |
210 } | 211 } |
211 | 212 |
212 void PluginProxyTestHarness::TearDownHarness() { | 213 void PluginProxyTestHarness::TearDownHarness() { |
213 plugin_dispatcher_->DidDestroyInstance(pp_instance()); | 214 plugin_dispatcher_->DidDestroyInstance(pp_instance()); |
214 plugin_dispatcher_.reset(); | 215 plugin_dispatcher_.reset(); |
215 | 216 |
216 resource_tracker().DidDeleteInstance(pp_instance()); | 217 resource_tracker().DidDeleteInstance(pp_instance()); |
217 plugin_globals_.reset(); | 218 plugin_globals_.reset(); |
218 } | 219 } |
219 | 220 |
220 base::MessageLoopProxy* | 221 base::MessageLoopProxy* |
221 PluginProxyTestHarness::PluginDelegateMock::GetIPCMessageLoop() { | 222 PluginProxyTestHarness::PluginDelegateMock::GetIPCMessageLoop() { |
222 return ipc_message_loop_; | 223 return ipc_message_loop_; |
223 } | 224 } |
224 | 225 |
225 base::WaitableEvent* | 226 base::WaitableEvent* |
226 PluginProxyTestHarness::PluginDelegateMock::GetShutdownEvent() { | 227 PluginProxyTestHarness::PluginDelegateMock::GetShutdownEvent() { |
227 return shutdown_event_; | 228 return shutdown_event_; |
228 } | 229 } |
229 | 230 |
230 IPC::PlatformFileForTransit | 231 IPC::PlatformFileForTransit |
231 PluginProxyTestHarness::PluginDelegateMock::ShareHandleWithRemote( | 232 PluginProxyTestHarness::PluginDelegateMock::ShareHandleWithRemote( |
232 base::PlatformFile handle, | 233 base::PlatformFile handle, |
233 const IPC::SyncChannel& /* channel */, | 234 base::ProcessId /* remote_pid */, |
234 bool should_close_source) { | 235 bool should_close_source) { |
235 return IPC::GetFileHandleForProcess(handle, | 236 return IPC::GetFileHandleForProcess(handle, |
236 base::Process::Current().handle(), | 237 base::Process::Current().handle(), |
237 should_close_source); | 238 should_close_source); |
238 } | 239 } |
239 | 240 |
240 std::set<PP_Instance>* | 241 std::set<PP_Instance>* |
241 PluginProxyTestHarness::PluginDelegateMock::GetGloballySeenInstanceIDSet() { | 242 PluginProxyTestHarness::PluginDelegateMock::GetGloballySeenInstanceIDSet() { |
242 return &instance_id_set_; | 243 return &instance_id_set_; |
243 } | 244 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 // These must be first since the dispatcher set-up uses them. | 332 // These must be first since the dispatcher set-up uses them. |
332 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | 333 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
333 delegate_mock_.Init(ipc_message_loop, shutdown_event); | 334 delegate_mock_.Init(ipc_message_loop, shutdown_event); |
334 | 335 |
335 host_dispatcher_.reset(new HostDispatcher( | 336 host_dispatcher_.reset(new HostDispatcher( |
336 pp_module(), | 337 pp_module(), |
337 &MockGetInterface, | 338 &MockGetInterface, |
338 status_receiver_.release(), | 339 status_receiver_.release(), |
339 PpapiPermissions::AllPermissions())); | 340 PpapiPermissions::AllPermissions())); |
340 ppapi::Preferences preferences; | 341 ppapi::Preferences preferences; |
341 host_dispatcher_->InitHostWithChannel(&delegate_mock_, channel_handle, | 342 host_dispatcher_->InitHostWithChannel(&delegate_mock_, |
| 343 base::kNullProcessId, channel_handle, |
342 is_client, preferences); | 344 is_client, preferences); |
343 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); | 345 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); |
344 } | 346 } |
345 | 347 |
346 void HostProxyTestHarness::TearDownHarness() { | 348 void HostProxyTestHarness::TearDownHarness() { |
347 HostDispatcher::RemoveForInstance(pp_instance()); | 349 HostDispatcher::RemoveForInstance(pp_instance()); |
348 host_dispatcher_.reset(); | 350 host_dispatcher_.reset(); |
349 host_globals_.reset(); | 351 host_globals_.reset(); |
350 } | 352 } |
351 | 353 |
352 base::MessageLoopProxy* | 354 base::MessageLoopProxy* |
353 HostProxyTestHarness::DelegateMock::GetIPCMessageLoop() { | 355 HostProxyTestHarness::DelegateMock::GetIPCMessageLoop() { |
354 return ipc_message_loop_; | 356 return ipc_message_loop_; |
355 } | 357 } |
356 | 358 |
357 base::WaitableEvent* HostProxyTestHarness::DelegateMock::GetShutdownEvent() { | 359 base::WaitableEvent* HostProxyTestHarness::DelegateMock::GetShutdownEvent() { |
358 return shutdown_event_; | 360 return shutdown_event_; |
359 } | 361 } |
360 | 362 |
361 IPC::PlatformFileForTransit | 363 IPC::PlatformFileForTransit |
362 HostProxyTestHarness::DelegateMock::ShareHandleWithRemote( | 364 HostProxyTestHarness::DelegateMock::ShareHandleWithRemote( |
363 base::PlatformFile handle, | 365 base::PlatformFile handle, |
364 const IPC::SyncChannel& /* channel */, | 366 base::ProcessId /* remote_pid */, |
365 bool should_close_source) { | 367 bool should_close_source) { |
366 return IPC::GetFileHandleForProcess(handle, | 368 return IPC::GetFileHandleForProcess(handle, |
367 base::Process::Current().handle(), | 369 base::Process::Current().handle(), |
368 should_close_source); | 370 should_close_source); |
369 } | 371 } |
370 | 372 |
371 | 373 |
372 // HostProxyTest --------------------------------------------------------------- | 374 // HostProxyTest --------------------------------------------------------------- |
373 | 375 |
374 HostProxyTest::HostProxyTest() { | 376 HostProxyTest::HostProxyTest() { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, | 456 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, |
455 base::Bind(&RunTaskOnRemoteHarness, | 457 base::Bind(&RunTaskOnRemoteHarness, |
456 task, | 458 task, |
457 &task_complete)); | 459 &task_complete)); |
458 task_complete.Wait(); | 460 task_complete.Wait(); |
459 } | 461 } |
460 | 462 |
461 | 463 |
462 } // namespace proxy | 464 } // namespace proxy |
463 } // namespace ppapi | 465 } // namespace ppapi |
OLD | NEW |