Chromium Code Reviews| Index: chrome/common/prefetch_argument_win.cc |
| diff --git a/chrome/common/prefetch_argument_win.cc b/chrome/common/prefetch_argument_win.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..876b53f54cd830c8a9393b2799a7a87abb234eb1 |
| --- /dev/null |
| +++ b/chrome/common/prefetch_argument_win.cc |
| @@ -0,0 +1,61 @@ |
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/common/prefetch_argument_win.h" |
| + |
| +#include <string> |
| + |
| +#include "base/command_line.h" |
| +#include "base/logging.h" |
| +#include "base/strings/stringprintf.h" |
| +#include "chrome/common/chrome_switches.h" |
| +#include "chrome/installer/util/browser_distribution.h" |
| +#include "components/startup_metric_utils/common/pre_read_field_trial_utils_win.h" |
| +#include "content/public/common/content_switches.h" |
| + |
| +namespace chrome { |
| + |
| +void AddWindowsPrefetchArgument(base::CommandLine* command_line) { |
| + DCHECK(command_line); |
| + |
| + bool ignored; |
| + bool trial_prefetch_argument = false; |
| + startup_metric_utils::GetPreReadOptions( |
| + BrowserDistribution::GetDistribution()->GetRegistryPath(), &ignored, |
| + &ignored, &ignored, &ignored, &trial_prefetch_argument); |
|
gab
2016/01/18 19:10:51
Make these parameters optional in GetPreReadOption
|
| + if (!trial_prefetch_argument) |
| + return; |
| + |
| + const std::string process_type = |
| + command_line->GetSwitchValueASCII(switches::kProcessType); |
| + |
| + // There can be 9 prefetch profiles per executable: a profile for launches |
| + // without a prefetch argument and a profile per /prefetch:# argument, where # |
| + // is [1, 8]. |
|
gab
2016/01/18 19:10:51
"prefetch argument" -> "/prefetch argument"
|
| + int prefetch_argument; |
|
gab
2016/01/18 19:10:52
Default initialize to 0 and add comment (and also
|
| + |
| + if (process_type.empty()) { |
| + // No prefetch argument when the browser process is launched in foreground. |
| + if (!command_line->HasSwitch(switches::kNoStartupWindow)) |
| + return; |
| + prefetch_argument = 1; |
|
gab
2016/01/18 19:10:51
Now that there is a default value above I think th
|
| + } else if (process_type == switches::kRendererProcess) { |
| + prefetch_argument = 2; |
| + } else if (process_type == switches::kGpuProcess) { |
| + prefetch_argument = 3; |
| + } else if (process_type == switches::kPpapiPluginProcess) { |
| + prefetch_argument = 4; |
| + } else { |
|
gab
2016/01/18 19:10:52
Worth adding one for the watcher process?
(don't
|
| + // Default prefetch argument, shared by all process types that don't have |
| + // 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
|
| + // prefetch anything for these process types, as it won't be able to observe |
|
gab
2016/01/18 19:10:51
no ","
|
| + // consistent file reads across launches. |
|
gab
2016/01/18 19:10:52
s/./, but at least by using a custom profile they
|
| + prefetch_argument = 8; |
| + } |
| + |
|
gab
2016/01/18 19:10:52
DCHECK_GE(prefetch_id, 0);
DCHECK_LE(prefetch_id,
|
| + command_line->AppendArg( |
|
gab
2016/01/18 19:10:52
if (prefetch_id != 0)
|
| + base::StringPrintf("/prefetch:%d", prefetch_argument)); |
| +} |
|
gab
2016/01/18 19:10:51
At the end (and also mention this as a requirement
|
| + |
| +} // namespace chrome |