OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> | 5 #include <windows.h> |
6 #include <shlwapi.h> | 6 #include <shlwapi.h> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/win/registry.h" | 14 #include "base/rand_util.h" // For PreReadExperiment. |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "base/version.h" | 17 #include "base/version.h" |
| 18 #include "base/win/registry.h" |
18 #include "chrome/app/breakpad_win.h" | 19 #include "chrome/app/breakpad_win.h" |
19 #include "chrome/app/client_util.h" | 20 #include "chrome/app/client_util.h" |
20 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
21 #include "chrome/common/chrome_result_codes.h" | 22 #include "chrome/common/chrome_result_codes.h" |
22 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
23 #include "chrome/installer/util/browser_distribution.h" | 24 #include "chrome/installer/util/browser_distribution.h" |
24 #include "chrome/installer/util/channel_info.h" | 25 #include "chrome/installer/util/channel_info.h" |
25 #include "chrome/installer/util/install_util.h" | 26 #include "chrome/installer/util/install_util.h" |
26 #include "chrome/installer/util/google_update_constants.h" | 27 #include "chrome/installer/util/google_update_constants.h" |
27 #include "chrome/installer/util/google_update_settings.h" | 28 #include "chrome/installer/util/google_update_settings.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // for other sections. We can skip over these pages to avoid a soft page | 120 // for other sections. We can skip over these pages to avoid a soft page |
120 // fault which may not occur during code execution. However skipping 4K at | 121 // fault which may not occur during code execution. However skipping 4K at |
121 // a time still has better performance over 32K and 16K according to data. | 122 // a time still has better performance over 32K and 16K according to data. |
122 // TODO(ananta): Investigate this and tune. | 123 // TODO(ananta): Investigate this and tune. |
123 const size_t kStepSize = 4 * 1024; | 124 const size_t kStepSize = 4 * 1024; |
124 | 125 |
125 DWORD pre_read_size = 0; | 126 DWORD pre_read_size = 0; |
126 DWORD pre_read_step_size = kStepSize; | 127 DWORD pre_read_step_size = kStepSize; |
127 DWORD pre_read = 1; | 128 DWORD pre_read = 1; |
128 | 129 |
| 130 // TODO(chrisha): This path should not be ChromeFrame specific, and it |
| 131 // should not be hard-coded with 'Google' in the path. Rather, it should |
| 132 // use the product name. |
129 base::win::RegKey key(HKEY_CURRENT_USER, L"Software\\Google\\ChromeFrame", | 133 base::win::RegKey key(HKEY_CURRENT_USER, L"Software\\Google\\ChromeFrame", |
130 KEY_QUERY_VALUE); | 134 KEY_QUERY_VALUE); |
131 if (key.Valid()) { | 135 if (key.Valid()) { |
132 key.ReadValueDW(L"PreReadSize", &pre_read_size); | 136 key.ReadValueDW(L"PreReadSize", &pre_read_size); |
133 key.ReadValueDW(L"PreReadStepSize", &pre_read_step_size); | 137 key.ReadValueDW(L"PreReadStepSize", &pre_read_step_size); |
134 key.ReadValueDW(L"PreRead", &pre_read); | 138 key.ReadValueDW(L"PreRead", &pre_read); |
135 key.Close(); | 139 key.Close(); |
136 } | 140 } |
| 141 |
| 142 // The Syzygy project is a competing optimization technique. Part of the |
| 143 // evaluation consists of an A/B experiment. As a baseline, we wish to |
| 144 // evaluate startup time with preread enabled and disabled. We can't use |
| 145 // base::FieldTrial as this only exists *after* chrome.dll is loaded. We |
| 146 // override the registry setting with a coin-toss for the duration of the |
| 147 // experiment. |
| 148 // NOTE: This experiment is intended for Canary and Dev only, and should be |
| 149 // removed from any branch heading out to beta and beyond! |
| 150 pre_read = base::RandInt(0, 1); |
| 151 DCHECK(pre_read == 0 || pre_read == 1); |
| 152 |
| 153 // We communicate the coin-toss result via a side-channel |
| 154 // (environment variable) to chrome.dll. This ensures that chrome.dll |
| 155 // only reports experiment results if it has been launched by a |
| 156 // chrome.exe that is actually running the experiment. |
| 157 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 158 DCHECK(env.get() != NULL); |
| 159 env->SetVar("CHROME_PRE_READ_EXPERIMENT", pre_read ? "1" : "0"); |
| 160 |
137 if (pre_read) { | 161 if (pre_read) { |
138 TRACE_EVENT_BEGIN_ETW("PreReadImage", 0, ""); | 162 TRACE_EVENT_BEGIN_ETW("PreReadImage", 0, ""); |
139 file_util::PreReadImage(dir->c_str(), pre_read_size, pre_read_step_size); | 163 file_util::PreReadImage(dir->c_str(), pre_read_size, pre_read_step_size); |
140 TRACE_EVENT_END_ETW("PreReadImage", 0, ""); | 164 TRACE_EVENT_END_ETW("PreReadImage", 0, ""); |
141 } | 165 } |
142 } | 166 } |
143 #endif // NDEBUG | 167 #endif // NDEBUG |
144 #endif // WIN_DISABLE_PREREAD | 168 #endif // WIN_DISABLE_PREREAD |
145 | 169 |
146 return ::LoadLibraryExW(dir->c_str(), NULL, | 170 return ::LoadLibraryExW(dir->c_str(), NULL, |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 } | 333 } |
310 }; | 334 }; |
311 | 335 |
312 MainDllLoader* MakeMainDllLoader() { | 336 MainDllLoader* MakeMainDllLoader() { |
313 #if defined(GOOGLE_CHROME_BUILD) | 337 #if defined(GOOGLE_CHROME_BUILD) |
314 return new ChromeDllLoader(); | 338 return new ChromeDllLoader(); |
315 #else | 339 #else |
316 return new ChromiumDllLoader(); | 340 return new ChromiumDllLoader(); |
317 #endif | 341 #endif |
318 } | 342 } |
OLD | NEW |