Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(605)

Side by Side Diff: content/browser/plugin_service_impl_browsertest.cc

Issue 14335017: content: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/browser/plugin_service_impl.h" 5 #include "content/browser/plugin_service_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 #endif 99 #endif
100 100
101 private: 101 private:
102 void Fail() { 102 void Fail() {
103 if (!expect_fail_) 103 if (!expect_fail_)
104 FAIL(); 104 FAIL();
105 QuitMessageLoop(); 105 QuitMessageLoop();
106 } 106 }
107 107
108 void QuitMessageLoop() { 108 void QuitMessageLoop() {
109 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 109 BrowserThread::PostTask(
110 MessageLoop::QuitClosure()); 110 BrowserThread::UI, FROM_HERE, base::MessageLoop::QuitClosure());
111 } 111 }
112 112
113 ResourceContext* context_; 113 ResourceContext* context_;
114 IPC::Channel* channel_; 114 IPC::Channel* channel_;
115 bool set_plugin_info_called_; 115 bool set_plugin_info_called_;
116 bool expect_fail_; 116 bool expect_fail_;
117 DISALLOW_COPY_AND_ASSIGN(MockPluginProcessHostClient); 117 DISALLOW_COPY_AND_ASSIGN(MockPluginProcessHostClient);
118 }; 118 };
119 119
120 class MockPluginServiceFilter : public content::PluginServiceFilter { 120 class MockPluginServiceFilter : public content::PluginServiceFilter {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 211 }
212 212
213 private: 213 private:
214 ResourceContext* context_; 214 ResourceContext* context_;
215 bool get_resource_context_called_; 215 bool get_resource_context_called_;
216 216
217 DISALLOW_COPY_AND_ASSIGN(MockCanceledPluginServiceClient); 217 DISALLOW_COPY_AND_ASSIGN(MockCanceledPluginServiceClient);
218 }; 218 };
219 219
220 void QuitUIMessageLoopFromIOThread() { 220 void QuitUIMessageLoopFromIOThread() {
221 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 221 BrowserThread::PostTask(
222 MessageLoop::QuitClosure()); 222 BrowserThread::UI, FROM_HERE, base::MessageLoop::QuitClosure());
223 } 223 }
224 224
225 void OpenChannelAndThenCancel(PluginProcessHost::Client* client) { 225 void OpenChannelAndThenCancel(PluginProcessHost::Client* client) {
226 OpenChannel(client); 226 OpenChannel(client);
227 // Immediately cancel it. This is guaranteed to work since PluginService needs 227 // Immediately cancel it. This is guaranteed to work since PluginService needs
228 // to consult its filter on the FILE thread. 228 // to consult its filter on the FILE thread.
229 PluginServiceImpl::GetInstance()->CancelOpenChannelToNpapiPlugin(client); 229 PluginServiceImpl::GetInstance()->CancelOpenChannelToNpapiPlugin(client);
230 // Before we terminate the test, add a roundtrip through the FILE thread to 230 // Before we terminate the test, add a roundtrip through the FILE thread to
231 // make sure that it's had a chance to post back to the IO thread. Then signal 231 // make sure that it's had a chance to post back to the IO thread. Then signal
232 // the UI thread to stop and exit the test. 232 // the UI thread to stop and exit the test.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 ASSERT_TRUE(info.mime_types.size()); 264 ASSERT_TRUE(info.mime_types.size());
265 ASSERT_EQ(kNPAPITestPluginMimeType, info.mime_types[0].mime_type); 265 ASSERT_EQ(kNPAPITestPluginMimeType, info.mime_types[0].mime_type);
266 set_plugin_info_called_ = true; 266 set_plugin_info_called_ = true;
267 } 267 }
268 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) OVERRIDE { 268 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) OVERRIDE {
269 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 269 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
270 set_on_found_plugin_process_host_called(); 270 set_on_found_plugin_process_host_called();
271 set_host(host); 271 set_host(host);
272 // This gets called right before we request the plugin<=>renderer channel, 272 // This gets called right before we request the plugin<=>renderer channel,
273 // so we have to post a task to cancel it. 273 // so we have to post a task to cancel it.
274 MessageLoop::current()->PostTask( 274 base::MessageLoop::current()->PostTask(
275 FROM_HERE, 275 FROM_HERE,
276 base::Bind(&PluginProcessHost::CancelPendingRequest, 276 base::Bind(&PluginProcessHost::CancelPendingRequest,
277 base::Unretained(host), this)); 277 base::Unretained(host),
278 MessageLoop::current()->PostTask( 278 this));
279 FROM_HERE, 279 base::MessageLoop::current()->PostTask(
280 base::Bind(&QuitUIMessageLoopFromIOThread)); 280 FROM_HERE, base::Bind(&QuitUIMessageLoopFromIOThread));
281 } 281 }
282 282
283 bool set_plugin_info_called() const { 283 bool set_plugin_info_called() const {
284 return set_plugin_info_called_; 284 return set_plugin_info_called_;
285 } 285 }
286 286
287 bool on_found_plugin_process_host_called() const { 287 bool on_found_plugin_process_host_called() const {
288 return on_found_plugin_process_host_called_; 288 return on_found_plugin_process_host_called_;
289 } 289 }
290 290
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 // We override this guy again since we don't want to cancel yet. 338 // We override this guy again since we don't want to cancel yet.
339 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) OVERRIDE { 339 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) OVERRIDE {
340 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 340 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
341 set_on_found_plugin_process_host_called(); 341 set_on_found_plugin_process_host_called();
342 set_host(host); 342 set_host(host);
343 } 343 }
344 344
345 virtual void OnSentPluginChannelRequest() OVERRIDE { 345 virtual void OnSentPluginChannelRequest() OVERRIDE {
346 on_sent_plugin_channel_request_called_ = true; 346 on_sent_plugin_channel_request_called_ = true;
347 host()->CancelSentRequest(this); 347 host()->CancelSentRequest(this);
348 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 348 BrowserThread::PostTask(
349 MessageLoop::QuitClosure()); 349 BrowserThread::UI, FROM_HERE, base::MessageLoop::QuitClosure());
350 } 350 }
351 351
352 bool on_sent_plugin_channel_request_called() const { 352 bool on_sent_plugin_channel_request_called() const {
353 return on_sent_plugin_channel_request_called_; 353 return on_sent_plugin_channel_request_called_;
354 } 354 }
355 355
356 private: 356 private:
357 bool on_sent_plugin_channel_request_called_; 357 bool on_sent_plugin_channel_request_called_;
358 358
359 DISALLOW_COPY_AND_ASSIGN(MockCanceledAfterSentPluginProcessHostClient); 359 DISALLOW_COPY_AND_ASSIGN(MockCanceledAfterSentPluginProcessHostClient);
(...skipping 10 matching lines...) Expand all
370 BrowserThread::IO, FROM_HERE, 370 BrowserThread::IO, FROM_HERE,
371 base::Bind(&OpenChannel, &mock_client)); 371 base::Bind(&OpenChannel, &mock_client));
372 RunMessageLoop(); 372 RunMessageLoop();
373 EXPECT_TRUE(mock_client.get_resource_context_called()); 373 EXPECT_TRUE(mock_client.get_resource_context_called());
374 EXPECT_TRUE(mock_client.set_plugin_info_called()); 374 EXPECT_TRUE(mock_client.set_plugin_info_called());
375 EXPECT_TRUE(mock_client.on_found_plugin_process_host_called()); 375 EXPECT_TRUE(mock_client.on_found_plugin_process_host_called());
376 EXPECT_TRUE(mock_client.on_sent_plugin_channel_request_called()); 376 EXPECT_TRUE(mock_client.on_sent_plugin_channel_request_called());
377 } 377 }
378 378
379 } // namespace content 379 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/plugin_service_impl.cc ('k') | content/browser/renderer_host/image_transport_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698