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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 Dispatcher* PluginProxyTestHarness::GetDispatcher() { | 150 Dispatcher* PluginProxyTestHarness::GetDispatcher() { |
151 return plugin_dispatcher_.get(); | 151 return plugin_dispatcher_.get(); |
152 } | 152 } |
153 | 153 |
154 void PluginProxyTestHarness::SetUpHarness() { | 154 void PluginProxyTestHarness::SetUpHarness() { |
155 // These must be first since the dispatcher set-up uses them. | 155 // These must be first since the dispatcher set-up uses them. |
156 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | 156 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
157 resource_tracker().DidCreateInstance(pp_instance()); | 157 resource_tracker().DidCreateInstance(pp_instance()); |
158 | 158 |
159 plugin_dispatcher_.reset(new PluginDispatcher( | 159 plugin_dispatcher_.reset(new PluginDispatcher( |
160 base::Process::Current().handle(), | |
161 &MockGetInterface, | 160 &MockGetInterface, |
162 false)); | 161 false)); |
163 plugin_dispatcher_->InitWithTestSink(&sink()); | 162 plugin_dispatcher_->InitWithTestSink(&sink()); |
164 plugin_dispatcher_->DidCreateInstance(pp_instance()); | 163 plugin_dispatcher_->DidCreateInstance(pp_instance()); |
165 } | 164 } |
166 | 165 |
167 void PluginProxyTestHarness::SetUpHarnessWithChannel( | 166 void PluginProxyTestHarness::SetUpHarnessWithChannel( |
168 const IPC::ChannelHandle& channel_handle, | 167 const IPC::ChannelHandle& channel_handle, |
169 base::MessageLoopProxy* ipc_message_loop, | 168 base::MessageLoopProxy* ipc_message_loop, |
170 base::WaitableEvent* shutdown_event, | 169 base::WaitableEvent* shutdown_event, |
171 bool is_client) { | 170 bool is_client) { |
172 // These must be first since the dispatcher set-up uses them. | 171 // These must be first since the dispatcher set-up uses them. |
173 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | 172 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
174 resource_tracker().DidCreateInstance(pp_instance()); | 173 resource_tracker().DidCreateInstance(pp_instance()); |
175 plugin_delegate_mock_.Init(ipc_message_loop, shutdown_event); | 174 plugin_delegate_mock_.Init(ipc_message_loop, shutdown_event); |
176 | 175 |
177 plugin_dispatcher_.reset(new PluginDispatcher( | 176 plugin_dispatcher_.reset(new PluginDispatcher( |
178 base::Process::Current().handle(), | |
179 &MockGetInterface, | 177 &MockGetInterface, |
180 false)); | 178 false)); |
181 plugin_dispatcher_->InitPluginWithChannel(&plugin_delegate_mock_, | 179 plugin_dispatcher_->InitPluginWithChannel(&plugin_delegate_mock_, |
182 channel_handle, | 180 channel_handle, |
183 is_client); | 181 is_client); |
184 plugin_dispatcher_->DidCreateInstance(pp_instance()); | 182 plugin_dispatcher_->DidCreateInstance(pp_instance()); |
185 } | 183 } |
186 | 184 |
187 void PluginProxyTestHarness::TearDownHarness() { | 185 void PluginProxyTestHarness::TearDownHarness() { |
188 plugin_dispatcher_->DidDestroyInstance(pp_instance()); | 186 plugin_dispatcher_->DidDestroyInstance(pp_instance()); |
189 plugin_dispatcher_.reset(); | 187 plugin_dispatcher_.reset(); |
190 | 188 |
191 resource_tracker().DidDeleteInstance(pp_instance()); | 189 resource_tracker().DidDeleteInstance(pp_instance()); |
192 } | 190 } |
193 | 191 |
194 base::MessageLoopProxy* | 192 base::MessageLoopProxy* |
195 PluginProxyTestHarness::PluginDelegateMock::GetIPCMessageLoop() { | 193 PluginProxyTestHarness::PluginDelegateMock::GetIPCMessageLoop() { |
196 return ipc_message_loop_; | 194 return ipc_message_loop_; |
197 } | 195 } |
198 | 196 |
199 base::WaitableEvent* | 197 base::WaitableEvent* |
200 PluginProxyTestHarness::PluginDelegateMock::GetShutdownEvent() { | 198 PluginProxyTestHarness::PluginDelegateMock::GetShutdownEvent() { |
201 return shutdown_event_; | 199 return shutdown_event_; |
202 } | 200 } |
203 | 201 |
| 202 IPC::PlatformFileForTransit |
| 203 PluginProxyTestHarness::PluginDelegateMock::ShareHandleWithRemote( |
| 204 base::PlatformFile handle, |
| 205 const IPC::SyncChannel& /* channel */, |
| 206 bool should_close_source) { |
| 207 return IPC::GetFileHandleForProcess(handle, |
| 208 base::Process::Current().handle(), |
| 209 should_close_source); |
| 210 } |
| 211 |
204 std::set<PP_Instance>* | 212 std::set<PP_Instance>* |
205 PluginProxyTestHarness::PluginDelegateMock::GetGloballySeenInstanceIDSet() { | 213 PluginProxyTestHarness::PluginDelegateMock::GetGloballySeenInstanceIDSet() { |
206 return &instance_id_set_; | 214 return &instance_id_set_; |
207 } | 215 } |
208 | 216 |
209 uint32 PluginProxyTestHarness::PluginDelegateMock::Register( | 217 uint32 PluginProxyTestHarness::PluginDelegateMock::Register( |
210 PluginDispatcher* plugin_dispatcher) { | 218 PluginDispatcher* plugin_dispatcher) { |
211 return 0; | 219 return 0; |
212 } | 220 } |
213 | 221 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 } | 267 } |
260 | 268 |
261 Dispatcher* HostProxyTestHarness::GetDispatcher() { | 269 Dispatcher* HostProxyTestHarness::GetDispatcher() { |
262 return host_dispatcher_.get(); | 270 return host_dispatcher_.get(); |
263 } | 271 } |
264 | 272 |
265 void HostProxyTestHarness::SetUpHarness() { | 273 void HostProxyTestHarness::SetUpHarness() { |
266 // These must be first since the dispatcher set-up uses them. | 274 // These must be first since the dispatcher set-up uses them. |
267 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | 275 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
268 host_dispatcher_.reset(new HostDispatcher( | 276 host_dispatcher_.reset(new HostDispatcher( |
269 base::Process::Current().handle(), | |
270 pp_module(), | 277 pp_module(), |
271 &MockGetInterface, | 278 &MockGetInterface, |
272 status_receiver_.get())); | 279 status_receiver_.get())); |
273 host_dispatcher_->InitWithTestSink(&sink()); | 280 host_dispatcher_->InitWithTestSink(&sink()); |
274 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); | 281 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); |
275 } | 282 } |
276 | 283 |
277 void HostProxyTestHarness::SetUpHarnessWithChannel( | 284 void HostProxyTestHarness::SetUpHarnessWithChannel( |
278 const IPC::ChannelHandle& channel_handle, | 285 const IPC::ChannelHandle& channel_handle, |
279 base::MessageLoopProxy* ipc_message_loop, | 286 base::MessageLoopProxy* ipc_message_loop, |
280 base::WaitableEvent* shutdown_event, | 287 base::WaitableEvent* shutdown_event, |
281 bool is_client) { | 288 bool is_client) { |
282 // These must be first since the dispatcher set-up uses them. | 289 // These must be first since the dispatcher set-up uses them. |
283 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | 290 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
284 delegate_mock_.Init(ipc_message_loop, shutdown_event); | 291 delegate_mock_.Init(ipc_message_loop, shutdown_event); |
285 | 292 |
286 host_dispatcher_.reset(new HostDispatcher( | 293 host_dispatcher_.reset(new HostDispatcher( |
287 base::Process::Current().handle(), | |
288 pp_module(), | 294 pp_module(), |
289 &MockGetInterface, | 295 &MockGetInterface, |
290 status_receiver_.get())); | 296 status_receiver_.get())); |
291 ppapi::Preferences preferences; | 297 ppapi::Preferences preferences; |
292 host_dispatcher_->InitHostWithChannel(&delegate_mock_, channel_handle, | 298 host_dispatcher_->InitHostWithChannel(&delegate_mock_, channel_handle, |
293 is_client, preferences); | 299 is_client, preferences); |
294 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); | 300 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); |
295 } | 301 } |
296 | 302 |
297 void HostProxyTestHarness::TearDownHarness() { | 303 void HostProxyTestHarness::TearDownHarness() { |
298 HostDispatcher::RemoveForInstance(pp_instance()); | 304 HostDispatcher::RemoveForInstance(pp_instance()); |
299 host_dispatcher_.reset(); | 305 host_dispatcher_.reset(); |
300 } | 306 } |
301 | 307 |
302 base::MessageLoopProxy* | 308 base::MessageLoopProxy* |
303 HostProxyTestHarness::DelegateMock::GetIPCMessageLoop() { | 309 HostProxyTestHarness::DelegateMock::GetIPCMessageLoop() { |
304 return ipc_message_loop_; | 310 return ipc_message_loop_; |
305 } | 311 } |
306 | 312 |
307 base::WaitableEvent* HostProxyTestHarness::DelegateMock::GetShutdownEvent() { | 313 base::WaitableEvent* HostProxyTestHarness::DelegateMock::GetShutdownEvent() { |
308 return shutdown_event_; | 314 return shutdown_event_; |
309 } | 315 } |
310 | 316 |
| 317 IPC::PlatformFileForTransit |
| 318 HostProxyTestHarness::DelegateMock::ShareHandleWithRemote( |
| 319 base::PlatformFile handle, |
| 320 const IPC::SyncChannel& /* channel */, |
| 321 bool should_close_source) { |
| 322 return IPC::GetFileHandleForProcess(handle, |
| 323 base::Process::Current().handle(), |
| 324 should_close_source); |
| 325 } |
| 326 |
311 | 327 |
312 // HostProxyTest --------------------------------------------------------------- | 328 // HostProxyTest --------------------------------------------------------------- |
313 | 329 |
314 HostProxyTest::HostProxyTest() { | 330 HostProxyTest::HostProxyTest() { |
315 } | 331 } |
316 | 332 |
317 HostProxyTest::~HostProxyTest() { | 333 HostProxyTest::~HostProxyTest() { |
318 } | 334 } |
319 | 335 |
320 void HostProxyTest::SetUp() { | 336 void HostProxyTest::SetUp() { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 remote_harness_torn_down.Wait(); | 398 remote_harness_torn_down.Wait(); |
383 | 399 |
384 local_harness_->TearDownHarness(); | 400 local_harness_->TearDownHarness(); |
385 | 401 |
386 io_thread_.Stop(); | 402 io_thread_.Stop(); |
387 } | 403 } |
388 | 404 |
389 | 405 |
390 } // namespace proxy | 406 } // namespace proxy |
391 } // namespace ppapi | 407 } // namespace ppapi |
OLD | NEW |