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

Side by Side Diff: chrome/test/automation/proxy_launcher.cc

Issue 12767006: [Cleanup] Remove StringPrintf from global namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, once more Created 7 years, 9 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 | Annotate | Revision Log
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 "chrome/test/automation/proxy_launcher.h" 5 #include "chrome/test/automation/proxy_launcher.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/environment.h" 9 #include "base/environment.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 sql::Connection db; 48 sql::Connection db;
49 base::FilePath history = 49 base::FilePath history =
50 user_data_dir.AppendASCII("Default").AppendASCII("History"); 50 user_data_dir.AppendASCII("Default").AppendASCII("History");
51 // Not all test profiles have a history file. 51 // Not all test profiles have a history file.
52 if (!file_util::PathExists(history)) 52 if (!file_util::PathExists(history))
53 return; 53 return;
54 54
55 ASSERT_TRUE(db.Open(history)); 55 ASSERT_TRUE(db.Open(history));
56 base::Time yesterday = base::Time::Now() - base::TimeDelta::FromDays(1); 56 base::Time yesterday = base::Time::Now() - base::TimeDelta::FromDays(1);
57 std::string yesterday_str = base::Int64ToString(yesterday.ToInternalValue()); 57 std::string yesterday_str = base::Int64ToString(yesterday.ToInternalValue());
58 std::string query = StringPrintf( 58 std::string query = base::StringPrintf(
59 "UPDATE segment_usage " 59 "UPDATE segment_usage "
60 "SET time_slot = %s " 60 "SET time_slot = %s "
61 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);", 61 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);",
62 yesterday_str.c_str()); 62 yesterday_str.c_str());
63 ASSERT_TRUE(db.Execute(query.c_str())); 63 ASSERT_TRUE(db.Execute(query.c_str()));
64 db.Close(); 64 db.Close();
65 file_util::EvictFileFromSystemCache(history); 65 file_util::EvictFileFromSystemCache(history);
66 } 66 }
67 67
68 } // namespace 68 } // namespace
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 return WaitForBrowserLaunch(wait_for_initial_loads); 148 return WaitForBrowserLaunch(wait_for_initial_loads);
149 } 149 }
150 150
151 void ProxyLauncher::CloseBrowserAndServer() { 151 void ProxyLauncher::CloseBrowserAndServer() {
152 QuitBrowser(); 152 QuitBrowser();
153 153
154 // Suppress spammy failures that seem to be occurring when running 154 // Suppress spammy failures that seem to be occurring when running
155 // the UI tests in single-process mode. 155 // the UI tests in single-process mode.
156 // TODO(jhughes): figure out why this is necessary at all, and fix it 156 // TODO(jhughes): figure out why this is necessary at all, and fix it
157 AssertAppNotRunning( 157 AssertAppNotRunning(
158 StringPrintf("Unable to quit all browser processes. Original PID %d", 158 base::StringPrintf(
159 process_id_)); 159 "Unable to quit all browser processes. Original PID %d",
160 process_id_));
160 161
161 DisconnectFromRunningBrowser(); 162 DisconnectFromRunningBrowser();
162 } 163 }
163 164
164 void ProxyLauncher::DisconnectFromRunningBrowser() { 165 void ProxyLauncher::DisconnectFromRunningBrowser() {
165 automation_proxy_.reset(); // Shut down IPC testing interface. 166 automation_proxy_.reset(); // Shut down IPC testing interface.
166 } 167 }
167 168
168 bool ProxyLauncher::LaunchBrowser(const LaunchState& state) { 169 bool ProxyLauncher::LaunchBrowser(const LaunchState& state) {
169 if (state.clear_profile || !temp_profile_dir_.IsValid()) { 170 if (state.clear_profile || !temp_profile_dir_.IsValid()) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 309 }
309 310
310 void ProxyLauncher::AssertAppNotRunning(const std::string& error_message) { 311 void ProxyLauncher::AssertAppNotRunning(const std::string& error_message) {
311 std::string final_error_message(error_message); 312 std::string final_error_message(error_message);
312 313
313 ChromeProcessList processes = GetRunningChromeProcesses(process_id_); 314 ChromeProcessList processes = GetRunningChromeProcesses(process_id_);
314 if (!processes.empty()) { 315 if (!processes.empty()) {
315 final_error_message += " Leftover PIDs: ["; 316 final_error_message += " Leftover PIDs: [";
316 for (ChromeProcessList::const_iterator it = processes.begin(); 317 for (ChromeProcessList::const_iterator it = processes.begin();
317 it != processes.end(); ++it) { 318 it != processes.end(); ++it) {
318 final_error_message += StringPrintf(" %d", *it); 319 final_error_message += base::StringPrintf(" %d", *it);
319 } 320 }
320 final_error_message += " ]"; 321 final_error_message += " ]";
321 } 322 }
322 ASSERT_TRUE(processes.empty()) << final_error_message; 323 ASSERT_TRUE(processes.empty()) << final_error_message;
323 } 324 }
324 325
325 bool ProxyLauncher::WaitForBrowserProcessToQuit( 326 bool ProxyLauncher::WaitForBrowserProcessToQuit(
326 base::TimeDelta timeout, 327 base::TimeDelta timeout,
327 int* exit_code) { 328 int* exit_code) {
328 #ifdef WAIT_FOR_DEBUGGER_ON_OPEN 329 #ifdef WAIT_FOR_DEBUGGER_ON_OPEN
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 return LaunchBrowserAndServer(state, wait_for_initial_loads); 593 return LaunchBrowserAndServer(state, wait_for_initial_loads);
593 } 594 }
594 595
595 void AnonymousProxyLauncher::TerminateConnection() { 596 void AnonymousProxyLauncher::TerminateConnection() {
596 CloseBrowserAndServer(); 597 CloseBrowserAndServer();
597 } 598 }
598 599
599 std::string AnonymousProxyLauncher::PrefixedChannelID() const { 600 std::string AnonymousProxyLauncher::PrefixedChannelID() const {
600 return channel_id_; 601 return channel_id_;
601 } 602 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698