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> | 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/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "chrome/common/chrome_constants.h" | 27 #include "chrome/common/chrome_constants.h" |
28 #include "chrome/common/chrome_result_codes.h" | 28 #include "chrome/common/chrome_result_codes.h" |
29 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
30 #include "chrome/common/env_vars.h" | 30 #include "chrome/common/env_vars.h" |
31 #include "chrome/installer/util/google_update_constants.h" | 31 #include "chrome/installer/util/google_update_constants.h" |
32 #include "chrome/installer/util/google_update_settings.h" | 32 #include "chrome/installer/util/google_update_settings.h" |
33 #include "chrome/installer/util/install_util.h" | 33 #include "chrome/installer/util/install_util.h" |
34 #include "chrome/installer/util/util_constants.h" | 34 #include "chrome/installer/util/util_constants.h" |
35 #include "components/breakpad/app/breakpad_client.h" | 35 #include "components/breakpad/app/breakpad_client.h" |
36 #include "components/breakpad/app/breakpad_win.h" | 36 #include "components/breakpad/app/breakpad_win.h" |
| 37 #include "components/metrics/client_info.h" |
37 #include "content/public/app/startup_helper_win.h" | 38 #include "content/public/app/startup_helper_win.h" |
38 #include "sandbox/win/src/sandbox.h" | 39 #include "sandbox/win/src/sandbox.h" |
39 | 40 |
40 namespace { | 41 namespace { |
41 // The entry point signature of chrome.dll. | 42 // The entry point signature of chrome.dll. |
42 typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*); | 43 typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*); |
43 | 44 |
44 typedef void (*RelaunchChromeBrowserWithNewCommandLineIfNeededFunc)(); | 45 typedef void (*RelaunchChromeBrowserWithNewCommandLineIfNeededFunc)(); |
45 | 46 |
46 base::LazyInstance<chrome::ChromeBreakpadClient>::Leaky | 47 base::LazyInstance<chrome::ChromeBreakpadClient>::Leaky |
(...skipping 21 matching lines...) Expand all Loading... |
68 | 69 |
69 // Return true if the build time predates the expiration time.. | 70 // Return true if the build time predates the expiration time.. |
70 return build_time < expiration_time; | 71 return build_time < expiration_time; |
71 } | 72 } |
72 | 73 |
73 // Get random unit values, i.e., in the range (0, 1), denoting a die-toss for | 74 // Get random unit values, i.e., in the range (0, 1), denoting a die-toss for |
74 // being in an experiment population and experimental group thereof. | 75 // being in an experiment population and experimental group thereof. |
75 void GetPreReadPopulationAndGroup(double* population, double* group) { | 76 void GetPreReadPopulationAndGroup(double* population, double* group) { |
76 // By default we use the metrics id for the user as stable pseudo-random | 77 // By default we use the metrics id for the user as stable pseudo-random |
77 // input to a hash. | 78 // input to a hash. |
78 std::string metrics_id; | 79 scoped_ptr<metrics::ClientInfo> client_info = |
79 GoogleUpdateSettings::LoadMetricsClientId(&metrics_id); | 80 GoogleUpdateSettings::LoadMetricsClientInfo(); |
80 | 81 |
81 // If this user has not metrics id, we fall back to a purely random value | 82 // If this user has no metrics id, we fall back to a purely random value per |
82 // per browser session. | 83 // browser session. |
83 const size_t kLength = 16; | 84 const size_t kLength = 16; |
84 std::string random_value(metrics_id.empty() ? base::RandBytesAsString(kLength) | 85 std::string random_value(client_info ? client_info->client_id |
85 : metrics_id); | 86 : base::RandBytesAsString(kLength)); |
86 | 87 |
87 // To interpret the value as a random number we hash it and read the first 8 | 88 // To interpret the value as a random number we hash it and read the first 8 |
88 // bytes of the hash as a unit-interval representing a die-toss for being in | 89 // bytes of the hash as a unit-interval representing a die-toss for being in |
89 // the experiment population and the second 8 bytes as a die-toss for being | 90 // the experiment population and the second 8 bytes as a die-toss for being |
90 // in various experiment groups. | 91 // in various experiment groups. |
91 unsigned char sha1_hash[base::kSHA1Length]; | 92 unsigned char sha1_hash[base::kSHA1Length]; |
92 base::SHA1HashBytes( | 93 base::SHA1HashBytes( |
93 reinterpret_cast<const unsigned char*>(random_value.c_str()), | 94 reinterpret_cast<const unsigned char*>(random_value.c_str()), |
94 random_value.size() * sizeof(random_value[0]), | 95 random_value.size() * sizeof(random_value[0]), |
95 sha1_hash); | 96 sha1_hash); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 } | 363 } |
363 }; | 364 }; |
364 | 365 |
365 MainDllLoader* MakeMainDllLoader() { | 366 MainDllLoader* MakeMainDllLoader() { |
366 #if defined(GOOGLE_CHROME_BUILD) | 367 #if defined(GOOGLE_CHROME_BUILD) |
367 return new ChromeDllLoader(); | 368 return new ChromeDllLoader(); |
368 #else | 369 #else |
369 return new ChromiumDllLoader(); | 370 return new ChromiumDllLoader(); |
370 #endif | 371 #endif |
371 } | 372 } |
OLD | NEW |