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

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: format 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
(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 bool ignored;
23 bool trial_prefetch_argument = false;
24 startup_metric_utils::GetPreReadOptions(
25 BrowserDistribution::GetDistribution()->GetRegistryPath(), &ignored,
26 &ignored, &ignored, &ignored, &trial_prefetch_argument);
gab 2016/01/18 19:10:51 Make these parameters optional in GetPreReadOption
27 if (!trial_prefetch_argument)
28 return;
29
30 const std::string process_type =
31 command_line->GetSwitchValueASCII(switches::kProcessType);
32
33 // There can be 9 prefetch profiles per executable: a profile for launches
34 // without a prefetch argument and a profile per /prefetch:# argument, where #
35 // is [1, 8].
gab 2016/01/18 19:10:51 "prefetch argument" -> "/prefetch argument"
36 int prefetch_argument;
gab 2016/01/18 19:10:52 Default initialize to 0 and add comment (and also
37
38 if (process_type.empty()) {
39 // No prefetch argument when the browser process is launched in foreground.
40 if (!command_line->HasSwitch(switches::kNoStartupWindow))
41 return;
42 prefetch_argument = 1;
gab 2016/01/18 19:10:51 Now that there is a default value above I think th
43 } else if (process_type == switches::kRendererProcess) {
44 prefetch_argument = 2;
45 } else if (process_type == switches::kGpuProcess) {
46 prefetch_argument = 3;
47 } else if (process_type == switches::kPpapiPluginProcess) {
48 prefetch_argument = 4;
49 } else {
gab 2016/01/18 19:10:52 Worth adding one for the watcher process? (don't
50 // Default prefetch argument, shared by all process types that don't have
51 // one specified explicitly. It is likely that the prefetcher will never
gab 2016/01/18 19:10:51 s/process types that don't have one specified expl
52 // prefetch anything for these process types, as it won't be able to observe
gab 2016/01/18 19:10:51 no ","
53 // consistent file reads across launches.
gab 2016/01/18 19:10:52 s/./, but at least by using a custom profile they
54 prefetch_argument = 8;
55 }
56
gab 2016/01/18 19:10:52 DCHECK_GE(prefetch_id, 0); DCHECK_LE(prefetch_id,
57 command_line->AppendArg(
gab 2016/01/18 19:10:52 if (prefetch_id != 0)
58 base::StringPrintf("/prefetch:%d", prefetch_argument));
59 }
gab 2016/01/18 19:10:51 At the end (and also mention this as a requirement
60
61 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698