| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/process/process.h" | 8 #include "base/process/process.h" |
| 9 #include "base/run_loop.h" |
| 9 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| 10 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/devtools/devtools_window.h" | 13 #include "chrome/browser/devtools/devtools_window.h" |
| 13 #include "chrome/browser/search/search.h" | 14 #include "chrome/browser/search/search.h" |
| 14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_commands.h" | 16 #include "chrome/browser/ui/browser_commands.h" |
| 16 #include "chrome/browser/ui/singleton_tabs.h" | 17 #include "chrome/browser/ui/singleton_tabs.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 WaitForLauncherThread(); | 117 WaitForLauncherThread(); |
| 117 WaitForMessageProcessing(wc); | 118 WaitForMessageProcessing(wc); |
| 118 return ProcessFromHandle(wc->GetRenderProcessHost()->GetHandle()); | 119 return ProcessFromHandle(wc->GetRenderProcessHost()->GetHandle()); |
| 119 } | 120 } |
| 120 | 121 |
| 121 // Ensures that the backgrounding / foregrounding gets a chance to run. | 122 // Ensures that the backgrounding / foregrounding gets a chance to run. |
| 122 void WaitForLauncherThread() { | 123 void WaitForLauncherThread() { |
| 123 content::BrowserThread::PostTaskAndReply( | 124 content::BrowserThread::PostTaskAndReply( |
| 124 content::BrowserThread::PROCESS_LAUNCHER, FROM_HERE, | 125 content::BrowserThread::PROCESS_LAUNCHER, FROM_HERE, |
| 125 base::Bind(&base::DoNothing), base::MessageLoop::QuitWhenIdleClosure()); | 126 base::Bind(&base::DoNothing), base::MessageLoop::QuitWhenIdleClosure()); |
| 126 base::MessageLoop::current()->Run(); | 127 base::RunLoop().Run(); |
| 127 } | 128 } |
| 128 | 129 |
| 129 // Implicitly waits for the renderer process associated with the specified | 130 // Implicitly waits for the renderer process associated with the specified |
| 130 // WebContents to process outstanding IPC messages by running some JavaScript | 131 // WebContents to process outstanding IPC messages by running some JavaScript |
| 131 // and waiting for the result. | 132 // and waiting for the result. |
| 132 void WaitForMessageProcessing(WebContents* wc) { | 133 void WaitForMessageProcessing(WebContents* wc) { |
| 133 bool result = false; | 134 bool result = false; |
| 134 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 135 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 135 wc, "window.domAutomationController.send(true);", &result)); | 136 wc, "window.domAutomationController.send(true);", &result)); |
| 136 ASSERT_TRUE(result); | 137 ASSERT_TRUE(result); |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 content::ExecuteScript(audio_tab_web_contents_, | 686 content::ExecuteScript(audio_tab_web_contents_, |
| 686 "document.getElementById('audioPlayer').play();")); | 687 "document.getElementById('audioPlayer').play();")); |
| 687 | 688 |
| 688 // Wait until the two pages are not backgrounded. | 689 // Wait until the two pages are not backgrounded. |
| 689 while (no_audio_process_.IsProcessBackgrounded() || | 690 while (no_audio_process_.IsProcessBackgrounded() || |
| 690 audio_process_.IsProcessBackgrounded()) { | 691 audio_process_.IsProcessBackgrounded()) { |
| 691 base::RunLoop().RunUntilIdle(); | 692 base::RunLoop().RunUntilIdle(); |
| 692 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); | 693 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); |
| 693 } | 694 } |
| 694 } | 695 } |
| OLD | NEW |