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 "base/win/win_util.h" |
14 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
15 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 const char kOnIninitializedEventHandleSwitch[] = "on-initialized-event-handle"; | 20 const char kOnIninitializedEventHandleSwitch[] = "on-initialized-event-handle"; |
20 const char kParentHandleSwitch[] = "parent-handle"; | 21 const char kParentHandleSwitch[] = "parent-handle"; |
21 const char kMainThreadIdSwitch[] = "main-thread-id"; | 22 const char kMainThreadIdSwitch[] = "main-thread-id"; |
22 | 23 |
23 void AppendHandleSwitch(const std::string& switch_name, | 24 void AppendHandleSwitch(const std::string& switch_name, |
24 HANDLE handle, | 25 HANDLE handle, |
25 base::CommandLine* command_line) { | 26 base::CommandLine* command_line) { |
26 command_line->AppendSwitchASCII( | 27 command_line->AppendSwitchASCII( |
27 switch_name, base::UintToString(reinterpret_cast<uint32_t>(handle))); | 28 switch_name, base::UintToString(base::win::HandleToUint32(handle))); |
28 } | 29 } |
29 | 30 |
30 uint32_t ReadUintSwitch(const base::CommandLine& command_line, | 31 uint32_t ReadUintSwitch(const base::CommandLine& command_line, |
31 const std::string& switch_name) { | 32 const std::string& switch_name) { |
32 std::string switch_string = command_line.GetSwitchValueASCII(switch_name); | 33 std::string switch_string = command_line.GetSwitchValueASCII(switch_name); |
33 unsigned int switch_uint = 0; | 34 unsigned int switch_uint = 0; |
34 if (switch_string.empty() || | 35 if (switch_string.empty() || |
35 !base::StringToUint(switch_string, &switch_uint)) { | 36 !base::StringToUint(switch_string, &switch_uint)) { |
36 DLOG(ERROR) << "Missing or invalid " << switch_name << " argument."; | 37 DLOG(ERROR) << "Missing or invalid " << switch_name << " argument."; |
37 return 0; | 38 return 0; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 !parent_process->IsValid()) { | 110 !parent_process->IsValid()) { |
110 // If one was valid and not the other, free the valid one. | 111 // If one was valid and not the other, free the valid one. |
111 on_initialized_event->Close(); | 112 on_initialized_event->Close(); |
112 parent_process->Close(); | 113 parent_process->Close(); |
113 *main_thread_id = 0; | 114 *main_thread_id = 0; |
114 return false; | 115 return false; |
115 } | 116 } |
116 | 117 |
117 return true; | 118 return true; |
118 } | 119 } |
OLD | NEW |