Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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/app/chrome_watcher_command_line_win.h" | 5 #include "chrome/app/chrome_watcher_command_line_win.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
| 16 | 16 |
| 17 #if defined(OS_WIN) | |
|
brettw
2015/11/18 19:24:16
Ditto
| |
| 18 #include "base/win/win_util.h" | |
| 19 #endif | |
| 20 | |
| 17 namespace { | 21 namespace { |
| 18 | 22 |
| 19 const char kOnIninitializedEventHandleSwitch[] = "on-initialized-event-handle"; | 23 const char kOnIninitializedEventHandleSwitch[] = "on-initialized-event-handle"; |
| 20 const char kParentHandleSwitch[] = "parent-handle"; | 24 const char kParentHandleSwitch[] = "parent-handle"; |
| 21 const char kMainThreadIdSwitch[] = "main-thread-id"; | 25 const char kMainThreadIdSwitch[] = "main-thread-id"; |
| 22 | 26 |
| 23 void AppendHandleSwitch(const std::string& switch_name, | 27 void AppendHandleSwitch(const std::string& switch_name, |
| 24 HANDLE handle, | 28 HANDLE handle, |
| 25 base::CommandLine* command_line) { | 29 base::CommandLine* command_line) { |
| 26 command_line->AppendSwitchASCII( | 30 command_line->AppendSwitchASCII( |
| 27 switch_name, base::UintToString(reinterpret_cast<uint32_t>(handle))); | 31 switch_name, base::UintToString(base::win::HandleToUint32(handle))); |
| 28 } | 32 } |
| 29 | 33 |
| 30 uint32_t ReadUintSwitch(const base::CommandLine& command_line, | 34 uint32_t ReadUintSwitch(const base::CommandLine& command_line, |
| 31 const std::string& switch_name) { | 35 const std::string& switch_name) { |
| 32 std::string switch_string = command_line.GetSwitchValueASCII(switch_name); | 36 std::string switch_string = command_line.GetSwitchValueASCII(switch_name); |
| 33 unsigned int switch_uint = 0; | 37 unsigned int switch_uint = 0; |
| 34 if (switch_string.empty() || | 38 if (switch_string.empty() || |
| 35 !base::StringToUint(switch_string, &switch_uint)) { | 39 !base::StringToUint(switch_string, &switch_uint)) { |
| 36 DLOG(ERROR) << "Missing or invalid " << switch_name << " argument."; | 40 DLOG(ERROR) << "Missing or invalid " << switch_name << " argument."; |
| 37 return 0; | 41 return 0; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 !parent_process->IsValid()) { | 113 !parent_process->IsValid()) { |
| 110 // If one was valid and not the other, free the valid one. | 114 // If one was valid and not the other, free the valid one. |
| 111 on_initialized_event->Close(); | 115 on_initialized_event->Close(); |
| 112 parent_process->Close(); | 116 parent_process->Close(); |
| 113 *main_thread_id = 0; | 117 *main_thread_id = 0; |
| 114 return false; | 118 return false; |
| 115 } | 119 } |
| 116 | 120 |
| 117 return true; | 121 return true; |
| 118 } | 122 } |
| OLD | NEW |