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 | 7 |
8 #include "chrome/app/main_dll_loader_win.h" | 8 #include "chrome/app/main_dll_loader_win.h" |
9 | 9 |
10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
11 #include "base/base_switches.h" | 11 #include "base/base_switches.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/environment.h" | 14 #include "base/environment.h" |
15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
19 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
21 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
23 #include "base/trace_event/trace_event.h" | 23 #include "base/trace_event/trace_event.h" |
24 #include "base/win/scoped_handle.h" | 24 #include "base/win/scoped_handle.h" |
25 #include "base/win/windows_version.h" | 25 #include "base/win/windows_version.h" |
26 #include "chrome/app/chrome_crash_reporter_client.h" | 26 #include "chrome/app/chrome_crash_reporter_client.h" |
27 #include "chrome/app/chrome_watcher_client_win.h" | 27 #include "chrome/app/chrome_watcher_client_win.h" |
28 #include "chrome/app/chrome_watcher_command_line_win.h" | 28 #include "chrome/app/chrome_watcher_command_line_win.h" |
29 #include "chrome/app/image_pre_reader_win.h" | 29 #include "chrome/app/file_pre_reader_win.h" |
30 #include "chrome/app/kasko_client.h" | 30 #include "chrome/app/kasko_client.h" |
31 #include "chrome/chrome_watcher/chrome_watcher_main_api.h" | 31 #include "chrome/chrome_watcher/chrome_watcher_main_api.h" |
32 #include "chrome/common/chrome_constants.h" | 32 #include "chrome/common/chrome_constants.h" |
33 #include "chrome/common/chrome_paths.h" | 33 #include "chrome/common/chrome_paths.h" |
34 #include "chrome/common/chrome_result_codes.h" | 34 #include "chrome/common/chrome_result_codes.h" |
35 #include "chrome/common/chrome_switches.h" | 35 #include "chrome/common/chrome_switches.h" |
36 #include "chrome/common/env_vars.h" | 36 #include "chrome/common/env_vars.h" |
37 #include "chrome/installer/util/google_update_constants.h" | 37 #include "chrome/installer/util/google_update_constants.h" |
38 #include "chrome/installer/util/google_update_settings.h" | 38 #include "chrome/installer/util/google_update_settings.h" |
39 #include "chrome/installer/util/install_util.h" | 39 #include "chrome/installer/util/install_util.h" |
(...skipping 16 matching lines...) Expand all Loading... |
56 | 56 |
57 // Loads |module| after setting the CWD to |module|'s directory. Returns a | 57 // Loads |module| after setting the CWD to |module|'s directory. Returns a |
58 // reference to the loaded module on success, or null on error. | 58 // reference to the loaded module on success, or null on error. |
59 HMODULE LoadModuleWithDirectory(const base::FilePath& module, bool pre_read) { | 59 HMODULE LoadModuleWithDirectory(const base::FilePath& module, bool pre_read) { |
60 ::SetCurrentDirectoryW(module.DirName().value().c_str()); | 60 ::SetCurrentDirectoryW(module.DirName().value().c_str()); |
61 | 61 |
62 if (pre_read) { | 62 if (pre_read) { |
63 // We pre-read the binary to warm the memory caches (fewer hard faults to | 63 // We pre-read the binary to warm the memory caches (fewer hard faults to |
64 // page parts of the binary in). | 64 // page parts of the binary in). |
65 const size_t kStepSize = 1024 * 1024; | 65 const size_t kStepSize = 1024 * 1024; |
66 size_t percent = 100; | 66 PreReadFile(module, kStepSize); |
67 ImagePreReader::PartialPreReadImage(module.value().c_str(), percent, | |
68 kStepSize); | |
69 } | 67 } |
70 | 68 |
71 return ::LoadLibraryExW(module.value().c_str(), nullptr, | 69 return ::LoadLibraryExW(module.value().c_str(), nullptr, |
72 LOAD_WITH_ALTERED_SEARCH_PATH); | 70 LOAD_WITH_ALTERED_SEARCH_PATH); |
73 } | 71 } |
74 | 72 |
75 void RecordDidRun(const base::FilePath& dll_path) { | 73 void RecordDidRun(const base::FilePath& dll_path) { |
76 bool system_level = !InstallUtil::IsPerUserInstall(dll_path); | 74 bool system_level = !InstallUtil::IsPerUserInstall(dll_path); |
77 GoogleUpdateSettings::UpdateDidRunState(true, system_level); | 75 GoogleUpdateSettings::UpdateDidRunState(true, system_level); |
78 } | 76 } |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 } | 340 } |
343 }; | 341 }; |
344 | 342 |
345 MainDllLoader* MakeMainDllLoader() { | 343 MainDllLoader* MakeMainDllLoader() { |
346 #if defined(GOOGLE_CHROME_BUILD) | 344 #if defined(GOOGLE_CHROME_BUILD) |
347 return new ChromeDllLoader(); | 345 return new ChromeDllLoader(); |
348 #else | 346 #else |
349 return new ChromiumDllLoader(); | 347 return new ChromiumDllLoader(); |
350 #endif | 348 #endif |
351 } | 349 } |
OLD | NEW |