Chromium Code Reviews| Index: chrome/common/switch_utils.cc |
| diff --git a/chrome/common/switch_utils.cc b/chrome/common/switch_utils.cc |
| index 1b0f6c6cf752ad8612a4f923fdaa60a227167e8e..742e0a92d95c8995beba40582dd8e99806ace531 100644 |
| --- a/chrome/common/switch_utils.cc |
| +++ b/chrome/common/switch_utils.cc |
| @@ -7,10 +7,17 @@ |
| #include <stddef.h> |
| #include "base/macros.h" |
| +#include "build/build_config.h" |
| #include "chrome/common/chrome_switches.h" |
| +#if defined(OS_WIN) |
| +#include "base/strings/string_util.h" |
| +#endif // defined(OS_WIN) |
| + |
| namespace switches { |
| +namespace { |
| + |
| // Switches enumerated here will be removed when a background instance of |
| // Chrome restarts itself. If your key is designed to only be used once, |
| // or if it does not make sense when restarting a background instance to |
| @@ -26,10 +33,31 @@ const char* const kSwitchesToRemoveOnAutorestart[] = { |
| switches::kWinJumplistAction |
| }; |
| +} // namespace |
| + |
| void RemoveSwitchesForAutostart( |
| std::map<std::string, base::CommandLine::StringType>* switch_list) { |
| for (size_t i = 0; i < arraysize(kSwitchesToRemoveOnAutorestart); ++i) |
| switch_list->erase(kSwitchesToRemoveOnAutorestart[i]); |
| + |
| +#if defined(OS_WIN) |
| + // When Chrome is relaunched, the Windows prefetch profile to use can change |
| + // (e.g. a process initially launched in background is relaunched in |
| + // foreground). Therefore, always remove Windows prefetch switches from |
| + // |switch_list| and let the code building the relaunch command line add a new |
| + // one afterwards when appropriate. The format of a Windows prefetch switch is |
| + // "/prefetch:#" where # is [1, 8]. |
|
gab
2016/02/25 20:22:23
It's never appropriate to re-add one I think as we
fdoray
2016/02/26 18:10:36
Done. We do need to re-add a switch when a backgro
|
| + static const char kPrefetchSwitchPrefix[] = "prefetch:"; |
| + for (auto it = switch_list->lower_bound(kPrefetchSwitchPrefix); |
| + it != switch_list->end();) { |
| + if (base::StartsWith(it->first, kPrefetchSwitchPrefix, |
| + base::CompareCase::SENSITIVE)) { |
| + switch_list->erase(it++); |
| + } else { |
| + break; |
| + } |
| + } |
|
gab
2016/02/25 20:22:23
This loop assumes there can be more than one prefe
fdoray
2016/02/26 18:10:36
Done.
|
| +#endif // defined(OS_WIN) |
| } |
| } // namespace switches |