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 field-trial. |
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 // Use 'PreReadExperiment' rather than 'PreRead' for now. |
139 // key.ReadValueDW(L"PreRead", &pre_read); | |
140 | |
141 // The Syzygy project is a competing optimization technique. Part of the | |
142 // evaluation consists of an A/B experiment on Canary. As a baseline, we | |
143 // wish to evaluate startup time with preread enabled and disabled. We | |
144 // can't use base::FieldTrial as this only exists *after* chrome.dll is | |
145 // loaded, thus we store the result of our coin-toss in the registry. We | |
146 // do this using a separate registry key so that we can revert to the | |
147 // old behaviour after the experiment. | |
148 static const wchar_t kPreReadExperimentKey[] = L"PreReadExperiment"; | |
149 // Try to look up the earlier result. | |
150 if (key.ReadValueDW(kPreReadExperimentKey, &pre_read) != S_OK) { | |
151 // If this fails, toss a coin and save the result. The coin-toss is only | |
152 // used if it has been successfully written. We assert that the coin- | |
153 // toss produces a value of 0 or 1. While this amounts to storing a | |
154 // random number in the registry, it's range is too small to be used | |
155 // for any kind of user tracking. | |
156 DWORD coin_toss = base::RandInt(0, 1); | |
157 DCHECK(coin_toss == 0 || coin_toss == 1); | |
158 if (key.WriteValue(kPreReadExperimentKey, coin_toss) == S_OK) | |
159 pre_read = coin_toss; | |
160 } | |
161 | |
162 // We communicate the coin-toss result via a side-channel | |
163 // (environment variable) to chrome.dll. This ensures that chrome.dll | |
164 // only reports experiment results if it has been launched by a | |
165 // chrome.exe that is actually running the experiment. | |
166 scoped_ptr<base::Environment> env(base::Environment::Create()); | |
167 DCHECK(env.get() != NULL); | |
168 env->SetVar("CHROME_PRE_READ_EXPERIMENT", | |
Sigurður Ásgeirsson
2011/08/04 15:18:38
as we discussed, this only runs if the regkey exis
chrisha
2011/08/04 15:26:50
Done.
| |
169 pre_read ? "1" : "0"); | |
170 | |
135 key.Close(); | 171 key.Close(); |
136 } | 172 } |
137 if (pre_read) { | 173 if (pre_read) { |
138 TRACE_EVENT_BEGIN_ETW("PreReadImage", 0, ""); | 174 TRACE_EVENT_BEGIN_ETW("PreReadImage", 0, ""); |
139 file_util::PreReadImage(dir->c_str(), pre_read_size, pre_read_step_size); | 175 file_util::PreReadImage(dir->c_str(), pre_read_size, pre_read_step_size); |
140 TRACE_EVENT_END_ETW("PreReadImage", 0, ""); | 176 TRACE_EVENT_END_ETW("PreReadImage", 0, ""); |
141 } | 177 } |
142 } | 178 } |
143 #endif // NDEBUG | 179 #endif // NDEBUG |
144 #endif // WIN_DISABLE_PREREAD | 180 #endif // WIN_DISABLE_PREREAD |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 } | 345 } |
310 }; | 346 }; |
311 | 347 |
312 MainDllLoader* MakeMainDllLoader() { | 348 MainDllLoader* MakeMainDllLoader() { |
313 #if defined(GOOGLE_CHROME_BUILD) | 349 #if defined(GOOGLE_CHROME_BUILD) |
314 return new ChromeDllLoader(); | 350 return new ChromeDllLoader(); |
315 #else | 351 #else |
316 return new ChromiumDllLoader(); | 352 return new ChromiumDllLoader(); |
317 #endif | 353 #endif |
318 } | 354 } |
OLD | NEW |