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/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 &MockGetInterface, | 173 &MockGetInterface, |
174 PpapiPermissions(), | 174 PpapiPermissions(), |
175 false)); | 175 false)); |
176 plugin_dispatcher_->InitWithTestSink(&sink()); | 176 plugin_dispatcher_->InitWithTestSink(&sink()); |
177 // The plugin proxy delegate is needed for | 177 // The plugin proxy delegate is needed for |
178 // |PluginProxyDelegate::GetBrowserSender| which is used | 178 // |PluginProxyDelegate::GetBrowserSender| which is used |
179 // in |ResourceCreationProxy::GetConnection| to get the channel to the | 179 // in |ResourceCreationProxy::GetConnection| to get the channel to the |
180 // browser. In this case we just use the |plugin_dispatcher_| as the channel | 180 // browser. In this case we just use the |plugin_dispatcher_| as the channel |
181 // for test purposes. | 181 // for test purposes. |
182 plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); | 182 plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); |
183 PluginGlobals::Get()->set_plugin_proxy_delegate(&plugin_delegate_mock_); | 183 PluginGlobals::Get()->SetPluginProxyDelegate(&plugin_delegate_mock_); |
184 plugin_dispatcher_->DidCreateInstance(pp_instance()); | 184 plugin_dispatcher_->DidCreateInstance(pp_instance()); |
185 } | 185 } |
186 | 186 |
187 void PluginProxyTestHarness::SetUpHarnessWithChannel( | 187 void PluginProxyTestHarness::SetUpHarnessWithChannel( |
188 const IPC::ChannelHandle& channel_handle, | 188 const IPC::ChannelHandle& channel_handle, |
189 base::MessageLoopProxy* ipc_message_loop, | 189 base::MessageLoopProxy* ipc_message_loop, |
190 base::WaitableEvent* shutdown_event, | 190 base::WaitableEvent* shutdown_event, |
191 bool is_client) { | 191 bool is_client) { |
192 // These must be first since the dispatcher set-up uses them. | 192 // These must be first since the dispatcher set-up uses them. |
193 CreatePluginGlobals(); | 193 CreatePluginGlobals(); |
194 // Some of the methods called during set-up check that the lock is held. | 194 // Some of the methods called during set-up check that the lock is held. |
195 ProxyAutoLock lock; | 195 ProxyAutoLock lock; |
196 | 196 |
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 base::kNullProcessId, |
206 channel_handle, | 206 channel_handle, |
207 is_client); | 207 is_client); |
208 plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); | 208 plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); |
209 PluginGlobals::Get()->set_plugin_proxy_delegate(&plugin_delegate_mock_); | 209 PluginGlobals::Get()->SetPluginProxyDelegate(&plugin_delegate_mock_); |
210 plugin_dispatcher_->DidCreateInstance(pp_instance()); | 210 plugin_dispatcher_->DidCreateInstance(pp_instance()); |
211 } | 211 } |
212 | 212 |
213 void PluginProxyTestHarness::TearDownHarness() { | 213 void PluginProxyTestHarness::TearDownHarness() { |
214 { | 214 { |
215 // Some of the methods called during tear-down check that the lock is held. | 215 // Some of the methods called during tear-down check that the lock is held. |
216 ProxyAutoLock lock; | 216 ProxyAutoLock lock; |
217 | 217 |
218 plugin_dispatcher_->DidDestroyInstance(pp_instance()); | 218 plugin_dispatcher_->DidDestroyInstance(pp_instance()); |
219 plugin_dispatcher_.reset(); | 219 plugin_dispatcher_.reset(); |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, | 590 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, |
591 base::Bind(&RunTaskOnRemoteHarness, | 591 base::Bind(&RunTaskOnRemoteHarness, |
592 task, | 592 task, |
593 &task_complete)); | 593 &task_complete)); |
594 task_complete.Wait(); | 594 task_complete.Wait(); |
595 } | 595 } |
596 | 596 |
597 | 597 |
598 } // namespace proxy | 598 } // namespace proxy |
599 } // namespace ppapi | 599 } // namespace ppapi |
OLD | NEW |