Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: chrome/app/main_dll_loader_win.cc

Issue 1610733002: Store PreRead options obtained from the registry in a global variable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*); 57 typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*);
58 58
59 typedef void (*RelaunchChromeBrowserWithNewCommandLineIfNeededFunc)(); 59 typedef void (*RelaunchChromeBrowserWithNewCommandLineIfNeededFunc)();
60 60
61 // Loads |module| after setting the CWD to |module|'s directory. Returns a 61 // Loads |module| after setting the CWD to |module|'s directory. Returns a
62 // reference to the loaded module on success, or null on error. 62 // reference to the loaded module on success, or null on error.
63 HMODULE LoadModuleWithDirectory(const base::FilePath& module) { 63 HMODULE LoadModuleWithDirectory(const base::FilePath& module) {
64 ::SetCurrentDirectoryW(module.DirName().value().c_str()); 64 ::SetCurrentDirectoryW(module.DirName().value().c_str());
65 65
66 // Get pre-read options from the PreRead field trial. 66 // Get pre-read options from the PreRead field trial.
67 bool trial_no_pre_read = false; 67 startup_metric_utils::InitializePreReadOptions(
gab 2016/01/20 20:09:39 This makes me think that this is/was wrong, later
fdoray 2016/01/20 21:58:53 As we discussed, this isn't problematic as long as
68 bool trial_high_priority = false; 68 BrowserDistribution::GetDistribution()->GetRegistryPath());
69 bool trial_only_if_cold = false; 69 const int pre_read_options = startup_metric_utils::GetPreReadOptions();
70 bool trial_prefetch_virtual_memory = false;
71 startup_metric_utils::GetPreReadOptions(
72 BrowserDistribution::GetDistribution()->GetRegistryPath(),
73 &trial_no_pre_read, &trial_high_priority, &trial_only_if_cold,
74 &trial_prefetch_virtual_memory);
75 70
76 // Pre-read the binary to warm the memory caches (avoids a lot of random IO). 71 // Pre-read the binary to warm the memory caches (avoids a lot of random IO).
77 if (!trial_no_pre_read) { 72 if (!(pre_read_options & startup_metric_utils::PRE_READ_OPTION_NO_PRE_READ)) {
78 base::ThreadPriority previous_priority = base::ThreadPriority::NORMAL; 73 base::ThreadPriority previous_priority = base::ThreadPriority::NORMAL;
79 if (trial_high_priority) { 74 if (pre_read_options &
75 startup_metric_utils::PRE_READ_OPTION_HIGH_PRIORITY) {
80 previous_priority = base::PlatformThread::GetCurrentThreadPriority(); 76 previous_priority = base::PlatformThread::GetCurrentThreadPriority();
81 base::PlatformThread::SetCurrentThreadPriority( 77 base::PlatformThread::SetCurrentThreadPriority(
82 base::ThreadPriority::DISPLAY); 78 base::ThreadPriority::DISPLAY);
83 } 79 }
84 80
85 if (trial_only_if_cold) { 81 if (pre_read_options & startup_metric_utils::PRE_READ_OPTION_ONLY_IF_COLD) {
86 base::MemoryMappedFile module_memory_map; 82 base::MemoryMappedFile module_memory_map;
87 const bool map_initialize_success = module_memory_map.Initialize(module); 83 const bool map_initialize_success = module_memory_map.Initialize(module);
88 DCHECK(map_initialize_success); 84 DCHECK(map_initialize_success);
89 if (!IsMemoryMappedFileWarm(module_memory_map)) { 85 if (!IsMemoryMappedFileWarm(module_memory_map)) {
90 if (trial_prefetch_virtual_memory) 86 if (pre_read_options &
87 startup_metric_utils::PRE_READ_OPTION_PREFETCH_VIRTUAL_MEMORY) {
91 PreReadMemoryMappedFile(module_memory_map, module); 88 PreReadMemoryMappedFile(module_memory_map, module);
92 else 89 } else {
93 PreReadFile(module); 90 PreReadFile(module);
91 }
94 } 92 }
95 } else if (trial_prefetch_virtual_memory) { 93 } else if (pre_read_options &
94 startup_metric_utils::PRE_READ_OPTION_PREFETCH_VIRTUAL_MEMORY) {
96 base::MemoryMappedFile module_memory_map; 95 base::MemoryMappedFile module_memory_map;
97 const bool map_initialize_success = module_memory_map.Initialize(module); 96 const bool map_initialize_success = module_memory_map.Initialize(module);
98 DCHECK(map_initialize_success); 97 DCHECK(map_initialize_success);
99 PreReadMemoryMappedFile(module_memory_map, module); 98 PreReadMemoryMappedFile(module_memory_map, module);
100 } else { 99 } else {
101 PreReadFile(module); 100 PreReadFile(module);
102 } 101 }
103 102
104 if (trial_high_priority) 103 if (pre_read_options & startup_metric_utils::PRE_READ_OPTION_HIGH_PRIORITY)
105 base::PlatformThread::SetCurrentThreadPriority(previous_priority); 104 base::PlatformThread::SetCurrentThreadPriority(previous_priority);
106 } 105 }
107 106
108 return ::LoadLibraryExW(module.value().c_str(), nullptr, 107 return ::LoadLibraryExW(module.value().c_str(), nullptr,
109 LOAD_WITH_ALTERED_SEARCH_PATH); 108 LOAD_WITH_ALTERED_SEARCH_PATH);
110 } 109 }
111 110
112 void RecordDidRun(const base::FilePath& dll_path) { 111 void RecordDidRun(const base::FilePath& dll_path) {
113 bool system_level = !InstallUtil::IsPerUserInstall(dll_path); 112 bool system_level = !InstallUtil::IsPerUserInstall(dll_path);
114 GoogleUpdateSettings::UpdateDidRunState(true, system_level); 113 GoogleUpdateSettings::UpdateDidRunState(true, system_level);
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 } 389 }
391 }; 390 };
392 391
393 MainDllLoader* MakeMainDllLoader() { 392 MainDllLoader* MakeMainDllLoader() {
394 #if defined(GOOGLE_CHROME_BUILD) 393 #if defined(GOOGLE_CHROME_BUILD)
395 return new ChromeDllLoader(); 394 return new ChromeDllLoader();
396 #else 395 #else
397 return new ChromiumDllLoader(); 396 return new ChromiumDllLoader();
398 #endif 397 #endif
399 } 398 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698