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

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

Issue 8872030: Removing MessageLoop::QuitTask() from content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix escaping Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "content/browser/plugin_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 ASSERT_EQ(kNPAPITestPluginMimeType, info.mime_types[0].mime_type); 68 ASSERT_EQ(kNPAPITestPluginMimeType, info.mime_types[0].mime_type);
69 set_plugin_info_called_ = true; 69 set_plugin_info_called_ = true;
70 } 70 }
71 71
72 MOCK_METHOD0(OnError, void()); 72 MOCK_METHOD0(OnError, void());
73 73
74 // Listener implementation. 74 // Listener implementation.
75 MOCK_METHOD1(OnMessageReceived, bool(const IPC::Message& message)); 75 MOCK_METHOD1(OnMessageReceived, bool(const IPC::Message& message));
76 void OnChannelConnected(int32 peer_pid) OVERRIDE { 76 void OnChannelConnected(int32 peer_pid) OVERRIDE {
77 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 77 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
78 new MessageLoop::QuitTask()); 78 MessageLoop::QuitClosure());
79 } 79 }
80 MOCK_METHOD0(OnChannelError, void()); 80 MOCK_METHOD0(OnChannelError, void());
81 MOCK_METHOD0(OnChannelDenied, void()); 81 MOCK_METHOD0(OnChannelDenied, void());
82 MOCK_METHOD0(OnChannelListenError, void()); 82 MOCK_METHOD0(OnChannelListenError, void());
83 83
84 private: 84 private:
85 const content::ResourceContext& context_; 85 const content::ResourceContext& context_;
86 IPC::Channel* channel_; 86 IPC::Channel* channel_;
87 bool set_plugin_info_called_; 87 bool set_plugin_info_called_;
88 DISALLOW_COPY_AND_ASSIGN(MockPluginProcessHostClient); 88 DISALLOW_COPY_AND_ASSIGN(MockPluginProcessHostClient);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 const content::ResourceContext& context_; 145 const content::ResourceContext& context_;
146 bool get_resource_context_called_; 146 bool get_resource_context_called_;
147 147
148 DISALLOW_COPY_AND_ASSIGN(MockCanceledPluginServiceClient); 148 DISALLOW_COPY_AND_ASSIGN(MockCanceledPluginServiceClient);
149 }; 149 };
150 150
151 void DoNothing() {} 151 void DoNothing() {}
152 152
153 void QuitUIMessageLoopFromIOThread() { 153 void QuitUIMessageLoopFromIOThread() {
154 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 154 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
155 new MessageLoop::QuitTask()); 155 MessageLoop::QuitClosure());
156 } 156 }
157 157
158 void OpenChannelAndThenCancel(PluginProcessHost::Client* client) { 158 void OpenChannelAndThenCancel(PluginProcessHost::Client* client) {
159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
160 // Start opening the channel 160 // Start opening the channel
161 PluginService::GetInstance()->OpenChannelToNpapiPlugin( 161 PluginService::GetInstance()->OpenChannelToNpapiPlugin(
162 0, 0, GURL(), GURL(), kNPAPITestPluginMimeType, client); 162 0, 0, GURL(), GURL(), kNPAPITestPluginMimeType, client);
163 // Immediately cancel it. This is guaranteed to work since PluginService needs 163 // Immediately cancel it. This is guaranteed to work since PluginService needs
164 // to consult its filter on the FILE thread. 164 // to consult its filter on the FILE thread.
165 PluginService::GetInstance()->CancelOpenChannelToNpapiPlugin(client); 165 PluginService::GetInstance()->CancelOpenChannelToNpapiPlugin(client);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) OVERRIDE { 273 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) OVERRIDE {
274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
275 set_on_found_plugin_process_host_called(); 275 set_on_found_plugin_process_host_called();
276 set_host(host); 276 set_host(host);
277 } 277 }
278 278
279 virtual void OnSentPluginChannelRequest() OVERRIDE { 279 virtual void OnSentPluginChannelRequest() OVERRIDE {
280 on_sent_plugin_channel_request_called_ = true; 280 on_sent_plugin_channel_request_called_ = true;
281 host()->CancelSentRequest(this); 281 host()->CancelSentRequest(this);
282 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 282 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
283 new MessageLoop::QuitTask()); 283 MessageLoop::QuitClosure());
284 } 284 }
285 285
286 bool on_sent_plugin_channel_request_called() const { 286 bool on_sent_plugin_channel_request_called() const {
287 return on_sent_plugin_channel_request_called_; 287 return on_sent_plugin_channel_request_called_;
288 } 288 }
289 289
290 private: 290 private:
291 bool on_sent_plugin_channel_request_called_; 291 bool on_sent_plugin_channel_request_called_;
292 292
293 DISALLOW_COPY_AND_ASSIGN(MockCanceledAfterSentPluginProcessHostClient); 293 DISALLOW_COPY_AND_ASSIGN(MockCanceledAfterSentPluginProcessHostClient);
294 }; 294 };
295 295
296 // Should not attempt to open a channel, since it should be canceled early on. 296 // Should not attempt to open a channel, since it should be canceled early on.
297 IN_PROC_BROWSER_TEST_F( 297 IN_PROC_BROWSER_TEST_F(
298 PluginServiceTest, CancelAfterSentOpenChannelToPluginProcessHost) { 298 PluginServiceTest, CancelAfterSentOpenChannelToPluginProcessHost) {
299 ::testing::StrictMock<MockCanceledAfterSentPluginProcessHostClient> 299 ::testing::StrictMock<MockCanceledAfterSentPluginProcessHostClient>
300 mock_client(browser()->profile()->GetResourceContext()); 300 mock_client(browser()->profile()->GetResourceContext());
301 BrowserThread::PostTask( 301 BrowserThread::PostTask(
302 BrowserThread::IO, FROM_HERE, 302 BrowserThread::IO, FROM_HERE,
303 base::Bind(&OpenChannel, &mock_client)); 303 base::Bind(&OpenChannel, &mock_client));
304 ui_test_utils::RunMessageLoop(); 304 ui_test_utils::RunMessageLoop();
305 EXPECT_TRUE(mock_client.get_resource_context_called()); 305 EXPECT_TRUE(mock_client.get_resource_context_called());
306 EXPECT_TRUE(mock_client.set_plugin_info_called()); 306 EXPECT_TRUE(mock_client.set_plugin_info_called());
307 EXPECT_TRUE(mock_client.on_found_plugin_process_host_called()); 307 EXPECT_TRUE(mock_client.on_found_plugin_process_host_called());
308 EXPECT_TRUE(mock_client.on_sent_plugin_channel_request_called()); 308 EXPECT_TRUE(mock_client.on_sent_plugin_channel_request_called());
309 } 309 }
310 310
311 } // namespace 311 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698