| 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 "chrome/test/base/in_process_browser_test.h" | 5 #include "chrome/test/base/in_process_browser_test.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/location.h" |
| 14 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/single_thread_task_runner.h" |
| 15 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/test/test_file_util.h" | 18 #include "base/test/test_file_util.h" |
| 19 #include "base/thread_task_runner_handle.h" |
| 17 #include "base/threading/non_thread_safe.h" | 20 #include "base/threading/non_thread_safe.h" |
| 18 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/lifetime/application_lifetime.h" | 22 #include "chrome/browser/lifetime/application_lifetime.h" |
| 20 #include "chrome/browser/net/net_error_tab_helper.h" | 23 #include "chrome/browser/net/net_error_tab_helper.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/profiles/profile_manager.h" | 25 #include "chrome/browser/profiles/profile_manager.h" |
| 23 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_finder.h" | 27 #include "chrome/browser/ui/browser_finder.h" |
| 25 #include "chrome/browser/ui/browser_list.h" | 28 #include "chrome/browser/ui/browser_list.h" |
| 26 #include "chrome/browser/ui/browser_list_observer.h" | 29 #include "chrome/browser/ui/browser_list_observer.h" |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 | 572 |
| 570 void InProcessBrowserTest::QuitBrowsers() { | 573 void InProcessBrowserTest::QuitBrowsers() { |
| 571 if (chrome::GetTotalBrowserCount() == 0) { | 574 if (chrome::GetTotalBrowserCount() == 0) { |
| 572 chrome::NotifyAppTerminating(); | 575 chrome::NotifyAppTerminating(); |
| 573 return; | 576 return; |
| 574 } | 577 } |
| 575 | 578 |
| 576 // Invoke AttemptExit on a running message loop. | 579 // Invoke AttemptExit on a running message loop. |
| 577 // AttemptExit exits the message loop after everything has been | 580 // AttemptExit exits the message loop after everything has been |
| 578 // shut down properly. | 581 // shut down properly. |
| 579 base::MessageLoopForUI::current()->PostTask(FROM_HERE, | 582 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 580 base::Bind(&chrome::AttemptExit)); | 583 FROM_HERE, base::Bind(&chrome::AttemptExit)); |
| 581 content::RunMessageLoop(); | 584 content::RunMessageLoop(); |
| 582 | 585 |
| 583 #if defined(OS_MACOSX) | 586 #if defined(OS_MACOSX) |
| 584 // chrome::AttemptExit() will attempt to close all browsers by deleting | 587 // chrome::AttemptExit() will attempt to close all browsers by deleting |
| 585 // their tab contents. The last tab contents being removed triggers closing of | 588 // their tab contents. The last tab contents being removed triggers closing of |
| 586 // the browser window. | 589 // the browser window. |
| 587 // | 590 // |
| 588 // On the Mac, this eventually reaches | 591 // On the Mac, this eventually reaches |
| 589 // -[BrowserWindowController windowWillClose:], which will post a deferred | 592 // -[BrowserWindowController windowWillClose:], which will post a deferred |
| 590 // -autorelease on itself to ultimately destroy the Browser object. The line | 593 // -autorelease on itself to ultimately destroy the Browser object. The line |
| 591 // below is necessary to pump these pending messages to ensure all Browsers | 594 // below is necessary to pump these pending messages to ensure all Browsers |
| 592 // get deleted. | 595 // get deleted. |
| 593 content::RunAllPendingInMessageLoop(); | 596 content::RunAllPendingInMessageLoop(); |
| 594 delete autorelease_pool_; | 597 delete autorelease_pool_; |
| 595 autorelease_pool_ = NULL; | 598 autorelease_pool_ = NULL; |
| 596 #endif | 599 #endif |
| 597 } | 600 } |
| OLD | NEW |