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

Side by Side Diff: chrome/test/chromedriver/chrome_launcher.cc

Issue 191673003: Implement ScopedFD in terms of ScopedGeneric. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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) 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"
15 #include "base/format_macros.h" 16 #include "base/format_macros.h"
16 #include "base/json/json_reader.h" 17 #include "base/json/json_reader.h"
17 #include "base/json/json_writer.h" 18 #include "base/json/json_writer.h"
18 #include "base/logging.h" 19 #include "base/logging.h"
19 #include "base/process/kill.h" 20 #include "base/process/kill.h"
20 #include "base/process/launch.h" 21 #include "base/process/launch.h"
21 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/string_util.h" 23 #include "base/strings/string_util.h"
23 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
24 #include "base/strings/utf_string_conversions.h" 25 #include "base/strings/utf_string_conversions.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 244
244 #if !defined(OS_WIN) 245 #if !defined(OS_WIN)
245 if (!capabilities.log_path.empty()) 246 if (!capabilities.log_path.empty())
246 options.environ["CHROME_LOG_FILE"] = capabilities.log_path; 247 options.environ["CHROME_LOG_FILE"] = capabilities.log_path;
247 if (capabilities.detach) 248 if (capabilities.detach)
248 options.new_process_group = true; 249 options.new_process_group = true;
249 #endif 250 #endif
250 251
251 #if defined(OS_POSIX) 252 #if defined(OS_POSIX)
252 base::FileHandleMappingVector no_stderr; 253 base::FileHandleMappingVector no_stderr;
253 int devnull = -1; 254 base::ScopedFD devnull;
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 = open("/dev/null", O_WRONLY); 258 devnull.reset(open("/dev/null", O_WRONLY));
agl 2014/03/18 06:52:05 this open should be wrapped in HANDLE_EINTR.
259 if (devnull == -1) 259 if (!devnull.is_valid())
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, STDERR_FILENO)); 261 no_stderr.push_back(std::make_pair(devnull.get(), 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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698