Chromium Code Reviews| Index: chrome/app/chrome_exe_main_win.cc |
| diff --git a/chrome/app/chrome_exe_main_win.cc b/chrome/app/chrome_exe_main_win.cc |
| index 2102ae1676d1a40c73f609b3226d11a70e7c7970..313c8d6fdbc5fa6ae34f5db10197bc6745a9d977 100644 |
| --- a/chrome/app/chrome_exe_main_win.cc |
| +++ b/chrome/app/chrome_exe_main_win.cc |
| @@ -17,19 +17,23 @@ |
| #include "base/lazy_instance.h" |
| #include "base/logging.h" |
| #include "base/macros.h" |
| +#include "base/strings/string_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "base/time/time.h" |
| #include "base/win/windows_version.h" |
| #include "chrome/app/chrome_crash_reporter_client.h" |
| #include "chrome/app/main_dll_loader_win.h" |
| +#include "chrome/app/prefetch_argument_win.h" |
| #include "chrome/browser/chrome_process_finder_win.h" |
| #include "chrome/browser/policy/policy_path_parser.h" |
| #include "chrome/common/chrome_paths_internal.h" |
| #include "chrome/common/chrome_switches.h" |
| +#include "chrome/installer/util/browser_distribution.h" |
| #include "chrome_elf/chrome_elf_main.h" |
| #include "components/crash/content/app/crash_reporter_client.h" |
| #include "components/crash/content/app/crashpad.h" |
| #include "components/startup_metric_utils/browser/startup_metric_utils.h" |
| +#include "components/startup_metric_utils/common/pre_read_field_trial_utils_win.h" |
| #include "content/public/common/content_switches.h" |
| #include "content/public/common/result_codes.h" |
| #include "third_party/crashpad/crashpad/handler/handler_main.h" |
| @@ -152,12 +156,20 @@ int RunAsCrashpadHandler(const base::CommandLine& command_line) { |
| scoped_ptr<char* []> argv_as_utf8(new char*[argv.size() + 1]); |
| std::vector<std::string> storage; |
| storage.reserve(argv.size()); |
| + |
| + size_t arg_append_index = 0; |
| for (size_t i = 0; i < argv.size(); ++i) { |
| + // Remove the /prefetch:# argument as it is not supported by Crashpad. |
|
gab
2016/01/29 19:39:28
Is it really /prefetch or any argument that starts
fdoray
2016/02/01 13:28:26
Done.
|
| + if (base::StartsWith(argv[i], L"/prefetch:", base::CompareCase::SENSITIVE)) |
| + continue; |
| + |
| storage.push_back(base::UTF16ToUTF8(argv[i])); |
| - argv_as_utf8[i] = &storage[i][0]; |
| + argv_as_utf8[arg_append_index] = &storage[arg_append_index][0]; |
| + ++arg_append_index; |
| } |
| - argv_as_utf8[argv.size()] = nullptr; |
| - return crashpad::HandlerMain(static_cast<int>(argv.size()), |
| + argv_as_utf8[arg_append_index] = nullptr; |
| + |
| + return crashpad::HandlerMain(static_cast<int>(storage.size()), |
| argv_as_utf8.get()); |
| } |
| @@ -183,10 +195,22 @@ int main() { |
| #endif |
| // Initialize the CommandLine singleton from the environment. |
| base::CommandLine::Init(0, nullptr); |
| + const base::CommandLine* command_line = |
| + base::CommandLine::ForCurrentProcess(); |
| + |
| + const std::string process_type = |
| + command_line->GetSwitchValueASCII(switches::kProcessType); |
| + |
| + startup_metric_utils::InitializePreReadOptions( |
| + BrowserDistribution::GetDistribution()->GetRegistryPath()); |
| - std::string process_type = |
| - base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| - switches::kProcessType); |
| + // Confirm that an explicit prefetch profile is used for all process types |
| + // except for the browser process. Any new process type will have to assign |
| + // itself a prefetch id. See kPrefetchArgument* constants in |
| + // content_switches.cc for details. |
| + DCHECK(!startup_metric_utils::GetPreReadOptions().use_prefetch_argument || |
| + process_type.empty() || |
| + HasValidWindowsPrefetchArgument(*command_line)); |
| if (process_type == switches::kCrashpadHandler) |
| return RunAsCrashpadHandler(*base::CommandLine::ForCurrentProcess()); |
| @@ -210,7 +234,7 @@ int main() { |
| if (base::win::GetVersion() >= base::win::VERSION_WIN7) |
| EnableHighDPISupport(); |
| - if (AttemptFastNotify(*base::CommandLine::ForCurrentProcess())) |
| + if (AttemptFastNotify(*command_line)) |
| return 0; |
| // Load and launch the chrome dll. *Everything* happens inside. |