| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <windows.h> // NOLINT | 5 #include <windows.h> // NOLINT |
| 6 #include <shlwapi.h> // NOLINT | 6 #include <shlwapi.h> // NOLINT |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <userenv.h> // NOLINT | 8 #include <userenv.h> // NOLINT |
| 9 | 9 |
| 10 #include "chrome/app/main_dll_loader_win.h" | 10 #include "chrome/app/main_dll_loader_win.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/app/chrome_watcher_client_win.h" | 32 #include "chrome/app/chrome_watcher_client_win.h" |
| 33 #include "chrome/app/chrome_watcher_command_line_win.h" | 33 #include "chrome/app/chrome_watcher_command_line_win.h" |
| 34 #include "chrome/app/file_pre_reader_win.h" | 34 #include "chrome/app/file_pre_reader_win.h" |
| 35 #include "chrome/app/kasko_client.h" | 35 #include "chrome/app/kasko_client.h" |
| 36 #include "chrome/chrome_watcher/chrome_watcher_main_api.h" | 36 #include "chrome/chrome_watcher/chrome_watcher_main_api.h" |
| 37 #include "chrome/common/chrome_constants.h" | 37 #include "chrome/common/chrome_constants.h" |
| 38 #include "chrome/common/chrome_paths.h" | 38 #include "chrome/common/chrome_paths.h" |
| 39 #include "chrome/common/chrome_result_codes.h" | 39 #include "chrome/common/chrome_result_codes.h" |
| 40 #include "chrome/common/chrome_switches.h" | 40 #include "chrome/common/chrome_switches.h" |
| 41 #include "chrome/common/env_vars.h" | 41 #include "chrome/common/env_vars.h" |
| 42 #include "chrome/installer/util/browser_distribution.h" | |
| 43 #include "chrome/installer/util/google_update_constants.h" | 42 #include "chrome/installer/util/google_update_constants.h" |
| 44 #include "chrome/installer/util/google_update_settings.h" | 43 #include "chrome/installer/util/google_update_settings.h" |
| 45 #include "chrome/installer/util/install_util.h" | 44 #include "chrome/installer/util/install_util.h" |
| 46 #include "chrome/installer/util/module_util_win.h" | 45 #include "chrome/installer/util/module_util_win.h" |
| 47 #include "chrome/installer/util/util_constants.h" | 46 #include "chrome/installer/util/util_constants.h" |
| 48 #include "components/crash/content/app/crash_reporter_client.h" | 47 #include "components/crash/content/app/crash_reporter_client.h" |
| 49 #include "components/crash/content/app/crashpad.h" | 48 #include "components/crash/content/app/crashpad.h" |
| 50 #include "components/startup_metric_utils/common/pre_read_field_trial_utils_win.
h" | 49 #include "components/startup_metric_utils/common/pre_read_field_trial_utils_win.
h" |
| 51 #include "content/public/app/sandbox_helper_win.h" | 50 #include "content/public/app/sandbox_helper_win.h" |
| 52 #include "content/public/common/content_switches.h" | 51 #include "content/public/common/content_switches.h" |
| 53 #include "sandbox/win/src/sandbox.h" | 52 #include "sandbox/win/src/sandbox.h" |
| 54 | 53 |
| 55 namespace { | 54 namespace { |
| 56 // The entry point signature of chrome.dll. | 55 // The entry point signature of chrome.dll. |
| 57 typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*); | 56 typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*); |
| 58 | 57 |
| 59 typedef void (*RelaunchChromeBrowserWithNewCommandLineIfNeededFunc)(); | 58 typedef void (*RelaunchChromeBrowserWithNewCommandLineIfNeededFunc)(); |
| 60 | 59 |
| 61 // Loads |module| after setting the CWD to |module|'s directory. Returns a | 60 // Loads |module| after setting the CWD to |module|'s directory. Returns a |
| 62 // reference to the loaded module on success, or null on error. | 61 // reference to the loaded module on success, or null on error. |
| 63 HMODULE LoadModuleWithDirectory(const base::FilePath& module) { | 62 HMODULE LoadModuleWithDirectory(const base::FilePath& module) { |
| 64 ::SetCurrentDirectoryW(module.DirName().value().c_str()); | 63 ::SetCurrentDirectoryW(module.DirName().value().c_str()); |
| 65 | 64 |
| 66 // Get pre-read options from the PreRead field trial. | 65 // Get pre-read options from the PreRead field trial. |
| 67 startup_metric_utils::InitializePreReadOptions( | |
| 68 BrowserDistribution::GetDistribution()->GetRegistryPath()); | |
| 69 const startup_metric_utils::PreReadOptions pre_read_options = | 66 const startup_metric_utils::PreReadOptions pre_read_options = |
| 70 startup_metric_utils::GetPreReadOptions(); | 67 startup_metric_utils::GetPreReadOptions(); |
| 71 | 68 |
| 72 // Pre-read the binary to warm the memory caches (avoids a lot of random IO). | 69 // Pre-read the binary to warm the memory caches (avoids a lot of random IO). |
| 73 if (!pre_read_options.no_pre_read) { | 70 if (pre_read_options.pre_read) { |
| 74 base::ThreadPriority previous_priority = base::ThreadPriority::NORMAL; | 71 base::ThreadPriority previous_priority = base::ThreadPriority::NORMAL; |
| 75 if (pre_read_options.high_priority) { | 72 if (pre_read_options.high_priority) { |
| 76 previous_priority = base::PlatformThread::GetCurrentThreadPriority(); | 73 previous_priority = base::PlatformThread::GetCurrentThreadPriority(); |
| 77 base::PlatformThread::SetCurrentThreadPriority( | 74 base::PlatformThread::SetCurrentThreadPriority( |
| 78 base::ThreadPriority::DISPLAY); | 75 base::ThreadPriority::DISPLAY); |
| 79 } | 76 } |
| 80 | 77 |
| 81 if (pre_read_options.only_if_cold) { | 78 if (pre_read_options.only_if_cold) { |
| 82 base::MemoryMappedFile module_memory_map; | 79 base::MemoryMappedFile module_memory_map; |
| 83 const bool map_initialize_success = module_memory_map.Initialize(module); | 80 const bool map_initialize_success = module_memory_map.Initialize(module); |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 } | 383 } |
| 387 }; | 384 }; |
| 388 | 385 |
| 389 MainDllLoader* MakeMainDllLoader() { | 386 MainDllLoader* MakeMainDllLoader() { |
| 390 #if defined(GOOGLE_CHROME_BUILD) | 387 #if defined(GOOGLE_CHROME_BUILD) |
| 391 return new ChromeDllLoader(); | 388 return new ChromeDllLoader(); |
| 392 #else | 389 #else |
| 393 return new ChromiumDllLoader(); | 390 return new ChromiumDllLoader(); |
| 394 #endif | 391 #endif |
| 395 } | 392 } |
| OLD | NEW |