Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: chrome/browser/metrics/variations/variations_service.cc

Issue 1269773002: Cleanup VersionInfo after componentization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <set> 7 #include <set>
8 8
9 #include "base/build_time.h" 9 #include "base/build_time.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/metrics/sparse_histogram.h" 12 #include "base/metrics/sparse_histogram.h"
13 #include "base/prefs/pref_registry_simple.h" 13 #include "base/prefs/pref_registry_simple.h"
14 #include "base/prefs/pref_service.h" 14 #include "base/prefs/pref_service.h"
15 #include "base/sys_info.h" 15 #include "base/sys_info.h"
16 #include "base/task_runner_util.h" 16 #include "base/task_runner_util.h"
17 #include "base/timer/elapsed_timer.h" 17 #include "base/timer/elapsed_timer.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "base/version.h" 19 #include "base/version.h"
20 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/metrics/variations/generated_resources_map.h" 21 #include "chrome/browser/metrics/variations/generated_resources_map.h"
22 #include "chrome/browser/metrics/variations/variations_url_constants.h" 22 #include "chrome/browser/metrics/variations/variations_url_constants.h"
23 #include "chrome/common/channel_info.h"
23 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
24 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
25 #include "components/metrics/metrics_state_manager.h" 26 #include "components/metrics/metrics_state_manager.h"
26 #include "components/network_time/network_time_tracker.h" 27 #include "components/network_time/network_time_tracker.h"
27 #include "components/pref_registry/pref_registry_syncable.h" 28 #include "components/pref_registry/pref_registry_syncable.h"
28 #include "components/variations/proto/variations_seed.pb.h" 29 #include "components/variations/proto/variations_seed.pb.h"
29 #include "components/variations/variations_seed_processor.h" 30 #include "components/variations/variations_seed_processor.h"
30 #include "components/variations/variations_seed_simulator.h" 31 #include "components/variations/variations_seed_simulator.h"
32 #include "components/version_info/version_info.h"
31 #include "content/public/browser/browser_thread.h" 33 #include "content/public/browser/browser_thread.h"
32 #include "net/base/load_flags.h" 34 #include "net/base/load_flags.h"
33 #include "net/base/net_errors.h" 35 #include "net/base/net_errors.h"
34 #include "net/base/network_change_notifier.h" 36 #include "net/base/network_change_notifier.h"
35 #include "net/base/url_util.h" 37 #include "net/base/url_util.h"
36 #include "net/http/http_response_headers.h" 38 #include "net/http/http_response_headers.h"
37 #include "net/http/http_status_code.h" 39 #include "net/http/http_status_code.h"
38 #include "net/http/http_util.h" 40 #include "net/http/http_util.h"
39 #include "net/url_request/url_fetcher.h" 41 #include "net/url_request/url_fetcher.h"
40 #include "net/url_request/url_request_status.h" 42 #include "net/url_request/url_request_status.h"
(...skipping 18 matching lines...) Expand all
59 // TODO(mad): To be removed when we stop updating the NetworkTimeTracker. 61 // TODO(mad): To be removed when we stop updating the NetworkTimeTracker.
60 // For the HTTP date headers, the resolution of the server time is 1 second. 62 // For the HTTP date headers, the resolution of the server time is 1 second.
61 const int64 kServerTimeResolutionMs = 1000; 63 const int64 kServerTimeResolutionMs = 1000;
62 64
63 // Wrapper around channel checking, used to enable channel mocking for 65 // Wrapper around channel checking, used to enable channel mocking for
64 // testing. If the current browser channel is not UNKNOWN, this will return 66 // testing. If the current browser channel is not UNKNOWN, this will return
65 // that channel value. Otherwise, if the fake channel flag is provided, this 67 // that channel value. Otherwise, if the fake channel flag is provided, this
66 // will return the fake channel. Failing that, this will return the UNKNOWN 68 // will return the fake channel. Failing that, this will return the UNKNOWN
67 // channel. 69 // channel.
68 variations::Study_Channel GetChannelForVariations() { 70 variations::Study_Channel GetChannelForVariations() {
69 switch (chrome::VersionInfo::GetChannel()) { 71 switch (chrome::GetChannel()) {
70 case version_info::Channel::CANARY: 72 case version_info::Channel::CANARY:
71 return variations::Study_Channel_CANARY; 73 return variations::Study_Channel_CANARY;
72 case version_info::Channel::DEV: 74 case version_info::Channel::DEV:
73 return variations::Study_Channel_DEV; 75 return variations::Study_Channel_DEV;
74 case version_info::Channel::BETA: 76 case version_info::Channel::BETA:
75 return variations::Study_Channel_BETA; 77 return variations::Study_Channel_BETA;
76 case version_info::Channel::STABLE: 78 case version_info::Channel::STABLE:
77 return variations::Study_Channel_STABLE; 79 return variations::Study_Channel_STABLE;
78 case version_info::Channel::UNKNOWN: 80 case version_info::Channel::UNKNOWN:
79 break; 81 break;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 base::Version GetVersionForSimulation() { 122 base::Version GetVersionForSimulation() {
121 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS) 123 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
122 const base::Version installed_version = 124 const base::Version installed_version =
123 UpgradeDetectorImpl::GetCurrentlyInstalledVersion(); 125 UpgradeDetectorImpl::GetCurrentlyInstalledVersion();
124 if (installed_version.IsValid()) 126 if (installed_version.IsValid())
125 return installed_version; 127 return installed_version;
126 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS) 128 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
127 129
128 // TODO(asvitkine): Get the version that will be used on restart instead of 130 // TODO(asvitkine): Get the version that will be used on restart instead of
129 // the current version on Android, iOS and ChromeOS. 131 // the current version on Android, iOS and ChromeOS.
130 return base::Version(chrome::VersionInfo().Version()); 132 return base::Version(version_info::GetVersionNumber());
131 } 133 }
132 134
133 // Gets the restrict parameter from |policy_pref_service| or from Chrome OS 135 // Gets the restrict parameter from |policy_pref_service| or from Chrome OS
134 // settings in the case of that platform. 136 // settings in the case of that platform.
135 std::string GetRestrictParameterPref(PrefService* policy_pref_service) { 137 std::string GetRestrictParameterPref(PrefService* policy_pref_service) {
136 std::string parameter; 138 std::string parameter;
137 #if defined(OS_CHROMEOS) 139 #if defined(OS_CHROMEOS)
138 chromeos::CrosSettings::Get()->GetString( 140 chromeos::CrosSettings::Get()->GetString(
139 chromeos::kVariationsRestrictParameter, &parameter); 141 chromeos::kVariationsRestrictParameter, &parameter);
140 #else 142 #else
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 VariationsService::~VariationsService() { 254 VariationsService::~VariationsService() {
253 } 255 }
254 256
255 bool VariationsService::CreateTrialsFromSeed() { 257 bool VariationsService::CreateTrialsFromSeed() {
256 create_trials_from_seed_called_ = true; 258 create_trials_from_seed_called_ = true;
257 259
258 variations::VariationsSeed seed; 260 variations::VariationsSeed seed;
259 if (!seed_store_.LoadSeed(&seed)) 261 if (!seed_store_.LoadSeed(&seed))
260 return false; 262 return false;
261 263
262 const chrome::VersionInfo current_version_info; 264 const base::Version current_version(version_info::GetVersionNumber());
263 const base::Version current_version(current_version_info.Version());
264 if (!current_version.IsValid()) 265 if (!current_version.IsValid())
265 return false; 266 return false;
266 267
267 variations::Study_Channel channel = GetChannelForVariations(); 268 variations::Study_Channel channel = GetChannelForVariations();
268 UMA_HISTOGRAM_SPARSE_SLOWLY("Variations.UserChannel", channel); 269 UMA_HISTOGRAM_SPARSE_SLOWLY("Variations.UserChannel", channel);
269 270
270 variations::VariationsSeedProcessor().CreateTrialsFromSeed( 271 variations::VariationsSeedProcessor().CreateTrialsFromSeed(
271 seed, 272 seed,
272 g_browser_process->GetApplicationLocale(), 273 g_browser_process->GetApplicationLocale(),
273 GetReferenceDateForExpiryChecks(local_state_), 274 GetReferenceDateForExpiryChecks(local_state_),
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 // Otherwise, update the pref with the current Chrome version and country. 720 // Otherwise, update the pref with the current Chrome version and country.
720 base::ListValue new_list_value; 721 base::ListValue new_list_value;
721 new_list_value.AppendString(version.GetString()); 722 new_list_value.AppendString(version.GetString());
722 new_list_value.AppendString(seed.country_code()); 723 new_list_value.AppendString(seed.country_code());
723 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, 724 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry,
724 new_list_value); 725 new_list_value);
725 return seed.country_code(); 726 return seed.country_code();
726 } 727 }
727 728
728 } // namespace chrome_variations 729 } // namespace chrome_variations
OLDNEW
« no previous file with comments | « chrome/browser/metrics/variations/variations_service.h ('k') | chrome/browser/nacl_host/nacl_browser_delegate_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698