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 "chrome/browser/metrics/variations/variations_service.h" | 5 #include "chrome/browser/metrics/variations/variations_service.h" |
6 | 6 |
7 #include "base/build_time.h" | 7 #include "base/build_time.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/metrics/sparse_histogram.h" | 10 #include "base/metrics/sparse_histogram.h" |
11 #include "base/prefs/pref_registry_simple.h" | 11 #include "base/prefs/pref_registry_simple.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
14 #include "base/task_runner_util.h" | 14 #include "base/task_runner_util.h" |
15 #include "base/timer/elapsed_timer.h" | 15 #include "base/timer/elapsed_timer.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "base/version.h" | 17 #include "base/version.h" |
18 #include "chrome/browser/metrics/variations/generated_resources_map.h" | 18 #include "chrome/browser/metrics/variations/generated_resources_map.h" |
19 #include "chrome/common/channel_info.h" | |
20 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
21 #include "components/metrics/metrics_state_manager.h" | 20 #include "components/metrics/metrics_state_manager.h" |
22 #include "components/network_time/network_time_tracker.h" | 21 #include "components/network_time/network_time_tracker.h" |
23 #include "components/pref_registry/pref_registry_syncable.h" | 22 #include "components/pref_registry/pref_registry_syncable.h" |
24 #include "components/variations/pref_names.h" | 23 #include "components/variations/pref_names.h" |
25 #include "components/variations/proto/variations_seed.pb.h" | 24 #include "components/variations/proto/variations_seed.pb.h" |
26 #include "components/variations/variations_seed_processor.h" | 25 #include "components/variations/variations_seed_processor.h" |
27 #include "components/variations/variations_seed_simulator.h" | 26 #include "components/variations/variations_seed_simulator.h" |
28 #include "components/variations/variations_url_constants.h" | 27 #include "components/variations/variations_url_constants.h" |
29 #include "components/version_info/version_info.h" | 28 #include "components/version_info/version_info.h" |
(...skipping 22 matching lines...) Expand all Loading... |
52 | 51 |
53 // TODO(mad): To be removed when we stop updating the NetworkTimeTracker. | 52 // TODO(mad): To be removed when we stop updating the NetworkTimeTracker. |
54 // For the HTTP date headers, the resolution of the server time is 1 second. | 53 // For the HTTP date headers, the resolution of the server time is 1 second. |
55 const int64 kServerTimeResolutionMs = 1000; | 54 const int64 kServerTimeResolutionMs = 1000; |
56 | 55 |
57 // Wrapper around channel checking, used to enable channel mocking for | 56 // Wrapper around channel checking, used to enable channel mocking for |
58 // testing. If the current browser channel is not UNKNOWN, this will return | 57 // testing. If the current browser channel is not UNKNOWN, this will return |
59 // that channel value. Otherwise, if the fake channel flag is provided, this | 58 // that channel value. Otherwise, if the fake channel flag is provided, this |
60 // will return the fake channel. Failing that, this will return the UNKNOWN | 59 // will return the fake channel. Failing that, this will return the UNKNOWN |
61 // channel. | 60 // channel. |
62 variations::Study_Channel GetChannelForVariations() { | 61 variations::Study_Channel GetChannelForVariations( |
63 switch (chrome::GetChannel()) { | 62 version_info::Channel product_channel) { |
| 63 switch (product_channel) { |
64 case version_info::Channel::CANARY: | 64 case version_info::Channel::CANARY: |
65 return variations::Study_Channel_CANARY; | 65 return variations::Study_Channel_CANARY; |
66 case version_info::Channel::DEV: | 66 case version_info::Channel::DEV: |
67 return variations::Study_Channel_DEV; | 67 return variations::Study_Channel_DEV; |
68 case version_info::Channel::BETA: | 68 case version_info::Channel::BETA: |
69 return variations::Study_Channel_BETA; | 69 return variations::Study_Channel_BETA; |
70 case version_info::Channel::STABLE: | 70 case version_info::Channel::STABLE: |
71 return variations::Study_Channel_STABLE; | 71 return variations::Study_Channel_STABLE; |
72 case version_info::Channel::UNKNOWN: | 72 case version_info::Channel::UNKNOWN: |
73 break; | 73 break; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 create_trials_from_seed_called_ = true; | 249 create_trials_from_seed_called_ = true; |
250 | 250 |
251 variations::VariationsSeed seed; | 251 variations::VariationsSeed seed; |
252 if (!seed_store_.LoadSeed(&seed)) | 252 if (!seed_store_.LoadSeed(&seed)) |
253 return false; | 253 return false; |
254 | 254 |
255 const base::Version current_version(version_info::GetVersionNumber()); | 255 const base::Version current_version(version_info::GetVersionNumber()); |
256 if (!current_version.IsValid()) | 256 if (!current_version.IsValid()) |
257 return false; | 257 return false; |
258 | 258 |
259 variations::Study_Channel channel = GetChannelForVariations(); | 259 variations::Study_Channel channel = |
| 260 GetChannelForVariations(client_->GetChannel()); |
260 UMA_HISTOGRAM_SPARSE_SLOWLY("Variations.UserChannel", channel); | 261 UMA_HISTOGRAM_SPARSE_SLOWLY("Variations.UserChannel", channel); |
261 | 262 |
262 const std::string latest_country = | 263 const std::string latest_country = |
263 local_state_->GetString(prefs::kVariationsCountry); | 264 local_state_->GetString(prefs::kVariationsCountry); |
264 variations::VariationsSeedProcessor().CreateTrialsFromSeed( | 265 variations::VariationsSeedProcessor().CreateTrialsFromSeed( |
265 seed, client_->GetApplicationLocale(), | 266 seed, client_->GetApplicationLocale(), |
266 GetReferenceDateForExpiryChecks(local_state_), current_version, channel, | 267 GetReferenceDateForExpiryChecks(local_state_), current_version, channel, |
267 GetCurrentFormFactor(), GetHardwareClass(), latest_country, | 268 GetCurrentFormFactor(), GetHardwareClass(), latest_country, |
268 LoadPermanentConsistencyCountry(current_version, latest_country), | 269 LoadPermanentConsistencyCountry(current_version, latest_country), |
269 base::Bind(&OverrideUIString)); | 270 base::Bind(&OverrideUIString)); |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 scoped_ptr<const base::FieldTrial::EntropyProvider> entropy_provider = | 653 scoped_ptr<const base::FieldTrial::EntropyProvider> entropy_provider = |
653 state_manager_->CreateEntropyProvider(); | 654 state_manager_->CreateEntropyProvider(); |
654 variations::VariationsSeedSimulator seed_simulator(*entropy_provider); | 655 variations::VariationsSeedSimulator seed_simulator(*entropy_provider); |
655 | 656 |
656 const std::string latest_country = | 657 const std::string latest_country = |
657 local_state_->GetString(prefs::kVariationsCountry); | 658 local_state_->GetString(prefs::kVariationsCountry); |
658 const variations::VariationsSeedSimulator::Result result = | 659 const variations::VariationsSeedSimulator::Result result = |
659 seed_simulator.SimulateSeedStudies( | 660 seed_simulator.SimulateSeedStudies( |
660 *seed, client_->GetApplicationLocale(), | 661 *seed, client_->GetApplicationLocale(), |
661 GetReferenceDateForExpiryChecks(local_state_), version, | 662 GetReferenceDateForExpiryChecks(local_state_), version, |
662 GetChannelForVariations(), GetCurrentFormFactor(), GetHardwareClass(), | 663 GetChannelForVariations(client_->GetChannel()), |
663 latest_country, | 664 GetCurrentFormFactor(), GetHardwareClass(), latest_country, |
664 LoadPermanentConsistencyCountry(version, latest_country)); | 665 LoadPermanentConsistencyCountry(version, latest_country)); |
665 | 666 |
666 UMA_HISTOGRAM_COUNTS_100("Variations.SimulateSeed.NormalChanges", | 667 UMA_HISTOGRAM_COUNTS_100("Variations.SimulateSeed.NormalChanges", |
667 result.normal_group_change_count); | 668 result.normal_group_change_count); |
668 UMA_HISTOGRAM_COUNTS_100("Variations.SimulateSeed.KillBestEffortChanges", | 669 UMA_HISTOGRAM_COUNTS_100("Variations.SimulateSeed.KillBestEffortChanges", |
669 result.kill_best_effort_group_change_count); | 670 result.kill_best_effort_group_change_count); |
670 UMA_HISTOGRAM_COUNTS_100("Variations.SimulateSeed.KillCriticalChanges", | 671 UMA_HISTOGRAM_COUNTS_100("Variations.SimulateSeed.KillCriticalChanges", |
671 result.kill_critical_group_change_count); | 672 result.kill_critical_group_change_count); |
672 | 673 |
673 UMA_HISTOGRAM_TIMES("Variations.SimulateSeed.Duration", timer.Elapsed()); | 674 UMA_HISTOGRAM_TIMES("Variations.SimulateSeed.Duration", timer.Elapsed()); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 // Otherwise, update the pref with the current Chrome version and country. | 757 // Otherwise, update the pref with the current Chrome version and country. |
757 base::ListValue new_list_value; | 758 base::ListValue new_list_value; |
758 new_list_value.AppendString(version.GetString()); | 759 new_list_value.AppendString(version.GetString()); |
759 new_list_value.AppendString(latest_country); | 760 new_list_value.AppendString(latest_country); |
760 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, | 761 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, |
761 new_list_value); | 762 new_list_value); |
762 return latest_country; | 763 return latest_country; |
763 } | 764 } |
764 | 765 |
765 } // namespace chrome_variations | 766 } // namespace chrome_variations |
OLD | NEW |