Chromium Code Reviews| Index: chrome/app/main_dll_loader_win.cc |
| diff --git a/chrome/app/main_dll_loader_win.cc b/chrome/app/main_dll_loader_win.cc |
| index a70a6787d1504d0f2ce48b52ae09ce9325ac2f9b..c959114371ec3f3dfe7369463c87e4398e1daf21 100644 |
| --- a/chrome/app/main_dll_loader_win.cc |
| +++ b/chrome/app/main_dll_loader_win.cc |
| @@ -64,35 +64,34 @@ HMODULE LoadModuleWithDirectory(const base::FilePath& module) { |
| ::SetCurrentDirectoryW(module.DirName().value().c_str()); |
| // Get pre-read options from the PreRead field trial. |
| - bool trial_no_pre_read = false; |
| - bool trial_high_priority = false; |
| - bool trial_only_if_cold = false; |
| - bool trial_prefetch_virtual_memory = false; |
| - startup_metric_utils::GetPreReadOptions( |
| - BrowserDistribution::GetDistribution()->GetRegistryPath(), |
| - &trial_no_pre_read, &trial_high_priority, &trial_only_if_cold, |
| - &trial_prefetch_virtual_memory); |
| + startup_metric_utils::InitializePreReadOptions( |
| + BrowserDistribution::GetDistribution()->GetRegistryPath()); |
| + const int pre_read_options = startup_metric_utils::GetPreReadOptions(); |
| // Pre-read the binary to warm the memory caches (avoids a lot of random IO). |
| - if (!trial_no_pre_read) { |
| + if (!(pre_read_options & startup_metric_utils::PRE_READ_OPTION_NO_PRE_READ)) { |
|
grt (UTC plus 2)
2016/01/21 04:24:00
i think this would be easier to read if pre_read_o
fdoray
2016/01/21 16:04:16
Done. Except that I didn't use :1 in the struct ->
grt (UTC plus 2)
2016/01/21 18:15:42
I find the data-driven loop in InitializePreReadOp
gab
2016/01/21 19:49:27
FWIW, I think the loop is actually more readable t
fdoray
2016/01/21 21:16:08
I kept the loop, as preferred by gab@.
|
| base::ThreadPriority previous_priority = base::ThreadPriority::NORMAL; |
| - if (trial_high_priority) { |
| + if (pre_read_options & |
| + startup_metric_utils::PRE_READ_OPTION_HIGH_PRIORITY) { |
| previous_priority = base::PlatformThread::GetCurrentThreadPriority(); |
| base::PlatformThread::SetCurrentThreadPriority( |
| base::ThreadPriority::DISPLAY); |
| } |
| - if (trial_only_if_cold) { |
| + if (pre_read_options & startup_metric_utils::PRE_READ_OPTION_ONLY_IF_COLD) { |
| base::MemoryMappedFile module_memory_map; |
| const bool map_initialize_success = module_memory_map.Initialize(module); |
| DCHECK(map_initialize_success); |
| if (!IsMemoryMappedFileWarm(module_memory_map)) { |
| - if (trial_prefetch_virtual_memory) |
| + if (pre_read_options & |
| + startup_metric_utils::PRE_READ_OPTION_PREFETCH_VIRTUAL_MEMORY) { |
| PreReadMemoryMappedFile(module_memory_map, module); |
| - else |
| + } else { |
| PreReadFile(module); |
| + } |
| } |
| - } else if (trial_prefetch_virtual_memory) { |
| + } else if (pre_read_options & |
| + startup_metric_utils::PRE_READ_OPTION_PREFETCH_VIRTUAL_MEMORY) { |
| base::MemoryMappedFile module_memory_map; |
| const bool map_initialize_success = module_memory_map.Initialize(module); |
| DCHECK(map_initialize_success); |
| @@ -101,7 +100,7 @@ HMODULE LoadModuleWithDirectory(const base::FilePath& module) { |
| PreReadFile(module); |
| } |
| - if (trial_high_priority) |
| + if (pre_read_options & startup_metric_utils::PRE_READ_OPTION_HIGH_PRIORITY) |
| base::PlatformThread::SetCurrentThreadPriority(previous_priority); |
| } |