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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 168 |
169 // These must be first since the dispatcher set-up uses them. | 169 // These must be first since the dispatcher set-up uses them. |
170 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | 170 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
171 resource_tracker().DidCreateInstance(pp_instance()); | 171 resource_tracker().DidCreateInstance(pp_instance()); |
172 | 172 |
173 plugin_dispatcher_.reset(new PluginDispatcher( | 173 plugin_dispatcher_.reset(new PluginDispatcher( |
174 &MockGetInterface, | 174 &MockGetInterface, |
175 PpapiPermissions(), | 175 PpapiPermissions(), |
176 false)); | 176 false)); |
177 plugin_dispatcher_->InitWithTestSink(&sink()); | 177 plugin_dispatcher_->InitWithTestSink(&sink()); |
178 plugin_dispatcher_->DidCreateInstance(pp_instance()); | |
179 // The plugin proxy delegate is needed for | 178 // The plugin proxy delegate is needed for |
180 // |PluginProxyDelegate::GetBrowserSender| which is used | 179 // |PluginProxyDelegate::GetBrowserSender| which is used |
181 // in |ResourceCreationProxy::GetConnection| to get the channel to the | 180 // in |ResourceCreationProxy::GetConnection| to get the channel to the |
182 // browser. In this case we just use the |plugin_dispatcher_| as the channel | 181 // browser. In this case we just use the |plugin_dispatcher_| as the channel |
183 // for test purposes. | 182 // for test purposes. |
184 plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); | 183 plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); |
185 PluginGlobals::Get()->set_plugin_proxy_delegate(&plugin_delegate_mock_); | 184 PluginGlobals::Get()->set_plugin_proxy_delegate(&plugin_delegate_mock_); |
| 185 plugin_dispatcher_->DidCreateInstance(pp_instance()); |
186 } | 186 } |
187 | 187 |
188 void PluginProxyTestHarness::SetUpHarnessWithChannel( | 188 void PluginProxyTestHarness::SetUpHarnessWithChannel( |
189 const IPC::ChannelHandle& channel_handle, | 189 const IPC::ChannelHandle& channel_handle, |
190 base::MessageLoopProxy* ipc_message_loop, | 190 base::MessageLoopProxy* ipc_message_loop, |
191 base::WaitableEvent* shutdown_event, | 191 base::WaitableEvent* shutdown_event, |
192 bool is_client) { | 192 bool is_client) { |
193 plugin_globals_.reset(new PluginGlobals(PpapiGlobals::ForTest())); | 193 plugin_globals_.reset(new PluginGlobals(PpapiGlobals::ForTest())); |
194 | 194 |
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 channel_handle, | 205 channel_handle, |
206 is_client); | 206 is_client); |
| 207 plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); |
| 208 PluginGlobals::Get()->set_plugin_proxy_delegate(&plugin_delegate_mock_); |
207 plugin_dispatcher_->DidCreateInstance(pp_instance()); | 209 plugin_dispatcher_->DidCreateInstance(pp_instance()); |
208 } | 210 } |
209 | 211 |
210 void PluginProxyTestHarness::TearDownHarness() { | 212 void PluginProxyTestHarness::TearDownHarness() { |
211 plugin_dispatcher_->DidDestroyInstance(pp_instance()); | 213 plugin_dispatcher_->DidDestroyInstance(pp_instance()); |
212 plugin_dispatcher_.reset(); | 214 plugin_dispatcher_.reset(); |
213 | 215 |
214 resource_tracker().DidDeleteInstance(pp_instance()); | 216 resource_tracker().DidDeleteInstance(pp_instance()); |
215 plugin_globals_.reset(); | 217 plugin_globals_.reset(); |
216 } | 218 } |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, | 454 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, |
453 base::Bind(&RunTaskOnRemoteHarness, | 455 base::Bind(&RunTaskOnRemoteHarness, |
454 task, | 456 task, |
455 &task_complete)); | 457 &task_complete)); |
456 task_complete.Wait(); | 458 task_complete.Wait(); |
457 } | 459 } |
458 | 460 |
459 | 461 |
460 } // namespace proxy | 462 } // namespace proxy |
461 } // namespace ppapi | 463 } // namespace ppapi |
OLD | NEW |