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

Side by Side Diff: content/shell/browser/blink_test_controller.cc

Issue 1159623009: content: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test build fix. Created 5 years, 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/shell/browser/blink_test_controller.h" 5 #include "content/shell/browser/blink_test_controller.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/location.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/single_thread_task_runner.h"
13 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/thread_task_runner_handle.h"
15 #include "content/public/browser/devtools_agent_host.h" 17 #include "content/public/browser/devtools_agent_host.h"
16 #include "content/public/browser/dom_storage_context.h" 18 #include "content/public/browser/dom_storage_context.h"
17 #include "content/public/browser/gpu_data_manager.h" 19 #include "content/public/browser/gpu_data_manager.h"
18 #include "content/public/browser/navigation_controller.h" 20 #include "content/public/browser/navigation_controller.h"
19 #include "content/public/browser/navigation_entry.h" 21 #include "content/public/browser/navigation_entry.h"
20 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
21 #include "content/public/browser/notification_types.h" 23 #include "content/public/browser/notification_types.h"
22 #include "content/public/browser/render_process_host.h" 24 #include "content/public/browser/render_process_host.h"
23 #include "content/public/browser/render_view_host.h" 25 #include "content/public/browser/render_view_host.h"
24 #include "content/public/browser/render_widget_host_view.h" 26 #include "content/public/browser/render_widget_host_view.h"
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 IPC_END_MESSAGE_MAP() 395 IPC_END_MESSAGE_MAP()
394 396
395 return handled; 397 return handled;
396 } 398 }
397 399
398 void BlinkTestController::PluginCrashed(const base::FilePath& plugin_path, 400 void BlinkTestController::PluginCrashed(const base::FilePath& plugin_path,
399 base::ProcessId plugin_pid) { 401 base::ProcessId plugin_pid) {
400 DCHECK(CalledOnValidThread()); 402 DCHECK(CalledOnValidThread());
401 printer_->AddErrorMessage( 403 printer_->AddErrorMessage(
402 base::StringPrintf("#CRASHED - plugin (pid %d)", plugin_pid)); 404 base::StringPrintf("#CRASHED - plugin (pid %d)", plugin_pid));
403 base::MessageLoop::current()->PostTask( 405 base::ThreadTaskRunnerHandle::Get()->PostTask(
404 FROM_HERE, 406 FROM_HERE,
405 base::Bind(base::IgnoreResult(&BlinkTestController::DiscardMainWindow), 407 base::Bind(base::IgnoreResult(&BlinkTestController::DiscardMainWindow),
406 base::Unretained(this))); 408 base::Unretained(this)));
407 } 409 }
408 410
409 void BlinkTestController::RenderViewCreated(RenderViewHost* render_view_host) { 411 void BlinkTestController::RenderViewCreated(RenderViewHost* render_view_host) {
410 DCHECK(CalledOnValidThread()); 412 DCHECK(CalledOnValidThread());
411 // Might be kNullProcessHandle, in which case we will receive a notification 413 // Might be kNullProcessHandle, in which case we will receive a notification
412 // later when the RenderProcessHost was created. 414 // later when the RenderProcessHost was created.
413 if (render_view_host->GetProcess()->GetHandle() != base::kNullProcessHandle) 415 if (render_view_host->GetProcess()->GetHandle() != base::kNullProcessHandle)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 DiscardMainWindow(); 476 DiscardMainWindow();
475 } 477 }
476 478
477 void BlinkTestController::DiscardMainWindow() { 479 void BlinkTestController::DiscardMainWindow() {
478 // If we're running a test, we need to close all windows and exit the message 480 // If we're running a test, we need to close all windows and exit the message
479 // loop. Otherwise, we're already outside of the message loop, and we just 481 // loop. Otherwise, we're already outside of the message loop, and we just
480 // discard the main window. 482 // discard the main window.
481 WebContentsObserver::Observe(NULL); 483 WebContentsObserver::Observe(NULL);
482 if (test_phase_ != BETWEEN_TESTS) { 484 if (test_phase_ != BETWEEN_TESTS) {
483 Shell::CloseAllWindows(); 485 Shell::CloseAllWindows();
484 base::MessageLoop::current()->PostTask(FROM_HERE, 486 base::ThreadTaskRunnerHandle::Get()->PostTask(
485 base::MessageLoop::QuitClosure()); 487 FROM_HERE, base::MessageLoop::QuitClosure());
486 test_phase_ = CLEAN_UP; 488 test_phase_ = CLEAN_UP;
487 } else if (main_window_) { 489 } else if (main_window_) {
488 main_window_->Close(); 490 main_window_->Close();
489 } 491 }
490 main_window_ = NULL; 492 main_window_ = NULL;
491 current_pid_ = base::kNullProcessId; 493 current_pid_ = base::kNullProcessId;
492 } 494 }
493 495
494 void BlinkTestController::SendTestConfiguration() { 496 void BlinkTestController::SendTestConfiguration() {
495 RenderViewHost* render_view_host = 497 RenderViewHost* render_view_host =
(...skipping 12 matching lines...) Expand all
508 render_view_host->GetRoutingID(), params)); 510 render_view_host->GetRoutingID(), params));
509 } 511 }
510 512
511 void BlinkTestController::OnTestFinished() { 513 void BlinkTestController::OnTestFinished() {
512 test_phase_ = CLEAN_UP; 514 test_phase_ = CLEAN_UP;
513 if (!printer_->output_finished()) 515 if (!printer_->output_finished())
514 printer_->PrintImageFooter(); 516 printer_->PrintImageFooter();
515 RenderViewHost* render_view_host = 517 RenderViewHost* render_view_host =
516 main_window_->web_contents()->GetRenderViewHost(); 518 main_window_->web_contents()->GetRenderViewHost();
517 main_window_->web_contents()->ExitFullscreen(); 519 main_window_->web_contents()->ExitFullscreen();
518 base::MessageLoop::current()->PostTask( 520 base::ThreadTaskRunnerHandle::Get()->PostTask(
519 FROM_HERE, 521 FROM_HERE,
520 base::Bind(base::IgnoreResult(&BlinkTestController::Send), 522 base::Bind(base::IgnoreResult(&BlinkTestController::Send),
521 base::Unretained(this), 523 base::Unretained(this),
522 new ShellViewMsg_Reset(render_view_host->GetRoutingID()))); 524 new ShellViewMsg_Reset(render_view_host->GetRoutingID())));
523 } 525 }
524 526
525 void BlinkTestController::OnImageDump(const std::string& actual_pixel_hash, 527 void BlinkTestController::OnImageDump(const std::string& actual_pixel_hash,
526 const SkBitmap& image) { 528 const SkBitmap& image) {
527 SkAutoLockPixels image_lock(image); 529 SkAutoLockPixels image_lock(image);
528 530
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 if (is_leak_detection_enabled_) { 675 if (is_leak_detection_enabled_) {
674 if (main_window_ && main_window_->web_contents()) { 676 if (main_window_ && main_window_->web_contents()) {
675 RenderViewHost* render_view_host = 677 RenderViewHost* render_view_host =
676 main_window_->web_contents()->GetRenderViewHost(); 678 main_window_->web_contents()->GetRenderViewHost();
677 render_view_host->Send( 679 render_view_host->Send(
678 new ShellViewMsg_TryLeakDetection(render_view_host->GetRoutingID())); 680 new ShellViewMsg_TryLeakDetection(render_view_host->GetRoutingID()));
679 } 681 }
680 return; 682 return;
681 } 683 }
682 684
683 base::MessageLoop::current()->PostTask(FROM_HERE, 685 base::ThreadTaskRunnerHandle::Get()->PostTask(
684 base::MessageLoop::QuitClosure()); 686 FROM_HERE, base::MessageLoop::QuitClosure());
685 } 687 }
686 688
687 void BlinkTestController::OnLeakDetectionDone( 689 void BlinkTestController::OnLeakDetectionDone(
688 const LeakDetectionResult& result) { 690 const LeakDetectionResult& result) {
689 if (!result.leaked) { 691 if (!result.leaked) {
690 base::MessageLoop::current()->PostTask(FROM_HERE, 692 base::ThreadTaskRunnerHandle::Get()->PostTask(
691 base::MessageLoop::QuitClosure()); 693 FROM_HERE, base::MessageLoop::QuitClosure());
692 return; 694 return;
693 } 695 }
694 696
695 printer_->AddErrorMessage( 697 printer_->AddErrorMessage(
696 base::StringPrintf("#LEAK - renderer pid %d (%s)", current_pid_, 698 base::StringPrintf("#LEAK - renderer pid %d (%s)", current_pid_,
697 result.detail.c_str())); 699 result.detail.c_str()));
698 CHECK(!crash_when_leak_found_); 700 CHECK(!crash_when_leak_found_);
699 701
700 DiscardMainWindow(); 702 DiscardMainWindow();
701 } 703 }
702 704
703 } // namespace content 705 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/test_utils.cc ('k') | content/shell/browser/layout_test/layout_test_browser_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698