| 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..b6afdf54a5a569595a4e67caf865e08c5f2e94d8
|
| --- /dev/null
|
| +++ b/chrome/common/prefetch_argument_win.cc
|
| @@ -0,0 +1,62 @@
|
| +// 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);
|
| +
|
| + int pre_read_options = startup_metric_utils::GetPreReadOptions(
|
| + BrowserDistribution::GetDistribution()->GetRegistryPath());
|
| + if (pre_read_options & startup_metric_utils::NO_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].
|
| + int prefetch_id;
|
| +
|
| + if (process_type.empty()) {
|
| + // No prefetch argument when the browser process is launched in foreground.
|
| + if (!command_line->HasSwitch(switches::kNoStartupWindow))
|
| + return;
|
| + prefetch_id = 1;
|
| + } else if (process_type == switches::kRendererProcess) {
|
| + prefetch_id = 2;
|
| + } else if (process_type == switches::kGpuProcess) {
|
| + prefetch_id = 3;
|
| + } else if (process_type == switches::kPpapiPluginProcess) {
|
| + prefetch_id = 4;
|
| + } else {
|
| + // Default prefetch argument, shared by all other process types. It is
|
| + // likely that the prefetcher will never prefetch anything for these process
|
| + // types as it won't be able to observe consistent file reads across
|
| + // launches, but a least by using a custom profile they won't interfere with
|
| + // the default profile used by the browser process.
|
| + prefetch_id = 8;
|
| + }
|
| +
|
| + DCHECK_GE(prefetch_id, 0);
|
| + DCHECK_LE(prefetch_id, 8);
|
| +
|
| + if (prefetch_id != 0)
|
| + command_line->AppendArg(base::StringPrintf("/prefetch:%d", prefetch_id));
|
| +}
|
| +
|
| +} // namespace chrome
|
|
|