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

Side by Side Diff: content/public/test/test_utils.cc

Issue 2630683003: Revert of Convert more test helpers to base::RunLoop, fix page title checks. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « content/public/test/test_utils.h ('k') | content/test/content_browser_test_utils_internal.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/public/test/test_utils.h" 5 #include "content/public/test/test_utils.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 InProcessUtilityThreadHelper::InProcessUtilityThreadHelper() 308 InProcessUtilityThreadHelper::InProcessUtilityThreadHelper()
309 : child_thread_count_(0), shell_context_(new TestServiceManagerContext) { 309 : child_thread_count_(0), shell_context_(new TestServiceManagerContext) {
310 RenderProcessHost::SetRunRendererInProcess(true); 310 RenderProcessHost::SetRunRendererInProcess(true);
311 BrowserChildProcessObserver::Add(this); 311 BrowserChildProcessObserver::Add(this);
312 } 312 }
313 313
314 InProcessUtilityThreadHelper::~InProcessUtilityThreadHelper() { 314 InProcessUtilityThreadHelper::~InProcessUtilityThreadHelper() {
315 if (child_thread_count_) { 315 if (child_thread_count_) {
316 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::UI)); 316 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::UI));
317 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::IO)); 317 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::IO));
318 run_loop_.reset(new base::RunLoop); 318 runner_ = new MessageLoopRunner;
319 run_loop_->Run(); 319 runner_->Run();
320 } 320 }
321 BrowserChildProcessObserver::Remove(this); 321 BrowserChildProcessObserver::Remove(this);
322 RenderProcessHost::SetRunRendererInProcess(false); 322 RenderProcessHost::SetRunRendererInProcess(false);
323 } 323 }
324 324
325 void InProcessUtilityThreadHelper::BrowserChildProcessHostConnected( 325 void InProcessUtilityThreadHelper::BrowserChildProcessHostConnected(
326 const ChildProcessData& data) { 326 const ChildProcessData& data) {
327 child_thread_count_++; 327 child_thread_count_++;
328 } 328 }
329 329
330 void InProcessUtilityThreadHelper::BrowserChildProcessHostDisconnected( 330 void InProcessUtilityThreadHelper::BrowserChildProcessHostDisconnected(
331 const ChildProcessData& data) { 331 const ChildProcessData& data) {
332 if (--child_thread_count_) 332 if (--child_thread_count_)
333 return; 333 return;
334 334
335 if (run_loop_) 335 if (runner_.get())
336 run_loop_->Quit(); 336 runner_->Quit();
337 } 337 }
338 338
339 RenderFrameDeletedObserver::RenderFrameDeletedObserver(RenderFrameHost* rfh) 339 RenderFrameDeletedObserver::RenderFrameDeletedObserver(RenderFrameHost* rfh)
340 : WebContentsObserver(WebContents::FromRenderFrameHost(rfh)), 340 : WebContentsObserver(WebContents::FromRenderFrameHost(rfh)),
341 process_id_(rfh->GetProcess()->GetID()), 341 process_id_(rfh->GetProcess()->GetID()),
342 routing_id_(rfh->GetRoutingID()), 342 routing_id_(rfh->GetRoutingID()),
343 deleted_(false) {} 343 deleted_(false) {}
344 344
345 RenderFrameDeletedObserver::~RenderFrameDeletedObserver() {} 345 RenderFrameDeletedObserver::~RenderFrameDeletedObserver() {}
346 346
(...skipping 16 matching lines...) Expand all
363 if (deleted_) 363 if (deleted_)
364 return; 364 return;
365 365
366 runner_.reset(new base::RunLoop()); 366 runner_.reset(new base::RunLoop());
367 runner_->Run(); 367 runner_->Run();
368 runner_.reset(); 368 runner_.reset();
369 } 369 }
370 370
371 WebContentsDestroyedWatcher::WebContentsDestroyedWatcher( 371 WebContentsDestroyedWatcher::WebContentsDestroyedWatcher(
372 WebContents* web_contents) 372 WebContents* web_contents)
373 : WebContentsObserver(web_contents) { 373 : WebContentsObserver(web_contents),
374 message_loop_runner_(new MessageLoopRunner) {
374 EXPECT_TRUE(web_contents != NULL); 375 EXPECT_TRUE(web_contents != NULL);
375 } 376 }
376 377
377 WebContentsDestroyedWatcher::~WebContentsDestroyedWatcher() { 378 WebContentsDestroyedWatcher::~WebContentsDestroyedWatcher() {}
378 }
379 379
380 void WebContentsDestroyedWatcher::Wait() { 380 void WebContentsDestroyedWatcher::Wait() {
381 run_loop_.Run(); 381 message_loop_runner_->Run();
382 } 382 }
383 383
384 void WebContentsDestroyedWatcher::WebContentsDestroyed() { 384 void WebContentsDestroyedWatcher::WebContentsDestroyed() {
385 run_loop_.Quit(); 385 message_loop_runner_->Quit();
386 } 386 }
387 387
388 } // namespace content 388 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/test_utils.h ('k') | content/test/content_browser_test_utils_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698