| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/test/chromedriver/chrome_launcher.h" | 5 #include "chrome/test/chromedriver/chrome_launcher.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/files/scoped_file.h" | |
| 16 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
| 17 #include "base/json/json_reader.h" | 16 #include "base/json/json_reader.h" |
| 18 #include "base/json/json_writer.h" | 17 #include "base/json/json_writer.h" |
| 19 #include "base/logging.h" | 18 #include "base/logging.h" |
| 20 #include "base/process/kill.h" | 19 #include "base/process/kill.h" |
| 21 #include "base/process/launch.h" | 20 #include "base/process/launch.h" |
| 22 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 23 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 24 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 25 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 243 |
| 245 #if !defined(OS_WIN) | 244 #if !defined(OS_WIN) |
| 246 if (!capabilities.log_path.empty()) | 245 if (!capabilities.log_path.empty()) |
| 247 options.environ["CHROME_LOG_FILE"] = capabilities.log_path; | 246 options.environ["CHROME_LOG_FILE"] = capabilities.log_path; |
| 248 if (capabilities.detach) | 247 if (capabilities.detach) |
| 249 options.new_process_group = true; | 248 options.new_process_group = true; |
| 250 #endif | 249 #endif |
| 251 | 250 |
| 252 #if defined(OS_POSIX) | 251 #if defined(OS_POSIX) |
| 253 base::FileHandleMappingVector no_stderr; | 252 base::FileHandleMappingVector no_stderr; |
| 254 base::ScopedFD devnull; | 253 int devnull = -1; |
| 254 file_util::ScopedFD scoped_devnull(&devnull); |
| 255 if (!CommandLine::ForCurrentProcess()->HasSwitch("verbose")) { | 255 if (!CommandLine::ForCurrentProcess()->HasSwitch("verbose")) { |
| 256 // Redirect stderr to /dev/null, so that Chrome log spew doesn't confuse | 256 // Redirect stderr to /dev/null, so that Chrome log spew doesn't confuse |
| 257 // users. | 257 // users. |
| 258 devnull.reset(open("/dev/null", O_WRONLY)); | 258 devnull = open("/dev/null", O_WRONLY); |
| 259 if (!devnull.is_valid()) | 259 if (devnull == -1) |
| 260 return Status(kUnknownError, "couldn't open /dev/null"); | 260 return Status(kUnknownError, "couldn't open /dev/null"); |
| 261 no_stderr.push_back(std::make_pair(devnull.get(), STDERR_FILENO)); | 261 no_stderr.push_back(std::make_pair(devnull, STDERR_FILENO)); |
| 262 options.fds_to_remap = &no_stderr; | 262 options.fds_to_remap = &no_stderr; |
| 263 } | 263 } |
| 264 #endif | 264 #endif |
| 265 | 265 |
| 266 #if defined(OS_WIN) | 266 #if defined(OS_WIN) |
| 267 std::string command_string = base::WideToUTF8(command.GetCommandLineString()); | 267 std::string command_string = base::WideToUTF8(command.GetCommandLineString()); |
| 268 #else | 268 #else |
| 269 std::string command_string = command.GetCommandLineString(); | 269 std::string command_string = command.GetCommandLineString(); |
| 270 #endif | 270 #endif |
| 271 VLOG(0) << "Launching chrome: " << command_string; | 271 VLOG(0) << "Launching chrome: " << command_string; |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 // Write empty "First Run" file, otherwise Chrome will wipe the default | 683 // Write empty "First Run" file, otherwise Chrome will wipe the default |
| 684 // profile that was written. | 684 // profile that was written. |
| 685 if (base::WriteFile( | 685 if (base::WriteFile( |
| 686 user_data_dir.Append(chrome::kFirstRunSentinel), "", 0) != 0) { | 686 user_data_dir.Append(chrome::kFirstRunSentinel), "", 0) != 0) { |
| 687 return Status(kUnknownError, "failed to write first run file"); | 687 return Status(kUnknownError, "failed to write first run file"); |
| 688 } | 688 } |
| 689 return Status(kOk); | 689 return Status(kOk); |
| 690 } | 690 } |
| 691 | 691 |
| 692 } // namespace internal | 692 } // namespace internal |
| OLD | NEW |