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

Side by Side Diff: chrome/common/prefetch_argument_win.cc

Issue 1595633002: Use valid /prefetch arguments for process launches on Windows. - do not submit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move
Patch Set: address simple comments from gab 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
« no previous file with comments | « chrome/common/prefetch_argument_win.h ('k') | chrome/common/service_process_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/common/prefetch_argument_win.h"
6
7 #include <string>
8
9 #include "base/command_line.h"
10 #include "base/logging.h"
11 #include "base/strings/stringprintf.h"
12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/installer/util/browser_distribution.h"
14 #include "components/startup_metric_utils/common/pre_read_field_trial_utils_win. h"
15 #include "content/public/common/content_switches.h"
16
17 namespace chrome {
18
19 void AddWindowsPrefetchArgument(base::CommandLine* command_line) {
20 DCHECK(command_line);
21
22 int pre_read_options = startup_metric_utils::GetPreReadOptions(
23 BrowserDistribution::GetDistribution()->GetRegistryPath());
24 if (pre_read_options & startup_metric_utils::NO_PREFETCH_ARGUMENT)
25 return;
26
27 const std::string process_type =
28 command_line->GetSwitchValueASCII(switches::kProcessType);
29
30 // There can be 9 prefetch profiles per executable: a profile for launches
31 // without a /prefetch argument and a profile per /prefetch:# argument, where
32 // # is [1, 8].
33 int prefetch_id;
34
35 if (process_type.empty()) {
36 // No prefetch argument when the browser process is launched in foreground.
37 if (!command_line->HasSwitch(switches::kNoStartupWindow))
38 return;
39 prefetch_id = 1;
40 } else if (process_type == switches::kRendererProcess) {
41 prefetch_id = 2;
42 } else if (process_type == switches::kGpuProcess) {
43 prefetch_id = 3;
44 } else if (process_type == switches::kPpapiPluginProcess) {
45 prefetch_id = 4;
46 } else {
47 // Default prefetch argument, shared by all other process types. It is
48 // likely that the prefetcher will never prefetch anything for these process
49 // types as it won't be able to observe consistent file reads across
50 // launches, but a least by using a custom profile they won't interfere with
51 // the default profile used by the browser process.
52 prefetch_id = 8;
53 }
54
55 DCHECK_GE(prefetch_id, 0);
56 DCHECK_LE(prefetch_id, 8);
57
58 if (prefetch_id != 0)
59 command_line->AppendArg(base::StringPrintf("/prefetch:%d", prefetch_id));
60 }
61
62 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/common/prefetch_argument_win.h ('k') | chrome/common/service_process_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698