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

Side by Side Diff: chrome/app/chrome_watcher_command_line_win.cc

Issue 1612663002: Use a valid /prefetch argument when launching a process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bit
Patch Set: address comments from gab #10 Created 4 years, 11 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
OLDNEW
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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/win/win_util.h" 16 #include "base/win/win_util.h"
17 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
18 #include "components/startup_metric_utils/common/pre_read_field_trial_utils_win. h"
18 #include "content/public/common/content_switches.h" 19 #include "content/public/common/content_switches.h"
19 20
20 namespace { 21 namespace {
21 22
22 const char kMainThreadIdSwitch[] = "main-thread-id"; 23 const char kMainThreadIdSwitch[] = "main-thread-id";
23 const char kOnIninitializedEventHandleSwitch[] = "on-initialized-event-handle"; 24 const char kOnIninitializedEventHandleSwitch[] = "on-initialized-event-handle";
24 const char kParentHandleSwitch[] = "parent-handle"; 25 const char kParentHandleSwitch[] = "parent-handle";
25 26
26 void AppendHandleSwitch(const std::string& switch_name, 27 void AppendHandleSwitch(const std::string& switch_name,
27 HANDLE handle, 28 HANDLE handle,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 DWORD main_thread_id, 148 DWORD main_thread_id,
148 HANDLE on_initialized_event) { 149 HANDLE on_initialized_event) {
149 base::CommandLine command_line(chrome_exe); 150 base::CommandLine command_line(chrome_exe);
150 command_line.AppendSwitchASCII(switches::kProcessType, 151 command_line.AppendSwitchASCII(switches::kProcessType,
151 switches::kWatcherProcess); 152 switches::kWatcherProcess);
152 command_line.AppendSwitchASCII(kMainThreadIdSwitch, 153 command_line.AppendSwitchASCII(kMainThreadIdSwitch,
153 base::UintToString(main_thread_id)); 154 base::UintToString(main_thread_id));
154 AppendHandleSwitch(kOnIninitializedEventHandleSwitch, on_initialized_event, 155 AppendHandleSwitch(kOnIninitializedEventHandleSwitch, on_initialized_event,
155 &command_line); 156 &command_line);
156 AppendHandleSwitch(kParentHandleSwitch, parent_process, &command_line); 157 AppendHandleSwitch(kParentHandleSwitch, parent_process, &command_line);
158
159 #if defined(OS_WIN)
160 if (startup_metric_utils::GetPreReadOptions().use_prefetch_argument)
161 command_line.AppendArg(switches::kPrefetchArgumentWatcher);
162 #endif // defined(OS_WIN)
163
157 return command_line; 164 return command_line;
158 } 165 }
159 166
160 bool InterpretChromeWatcherCommandLine( 167 bool InterpretChromeWatcherCommandLine(
161 const base::CommandLine& command_line, 168 const base::CommandLine& command_line,
162 base::win::ScopedHandle* parent_process, 169 base::win::ScopedHandle* parent_process,
163 DWORD* main_thread_id, 170 DWORD* main_thread_id,
164 base::win::ScopedHandle* on_initialized_event) { 171 base::win::ScopedHandle* on_initialized_event) {
165 DCHECK(on_initialized_event); 172 DCHECK(on_initialized_event);
166 DCHECK(parent_process); 173 DCHECK(parent_process);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 !parent_process->IsValid()) { 212 !parent_process->IsValid()) {
206 // If one was valid and not the other, free the valid one. 213 // If one was valid and not the other, free the valid one.
207 on_initialized_event->Close(); 214 on_initialized_event->Close();
208 parent_process->Close(); 215 parent_process->Close();
209 *main_thread_id = 0; 216 *main_thread_id = 0;
210 return false; 217 return false;
211 } 218 }
212 219
213 return true; 220 return true;
214 } 221 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698