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

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

Issue 1310253004: Have VariationsService get version for simulation callback from client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@variations_service_browser_thread
Patch Set: Rebase Created 5 years, 3 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/chrome_variations_service_client.h" 5 #include "chrome/browser/metrics/variations/chrome_variations_service_client.h"
6 6
7 #include "base/bind.h"
7 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "components/version_info/version_info.h"
8 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
9 11
12 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
13 #include "chrome/browser/upgrade_detector_impl.h"
14 #endif
15
16 namespace {
17
18 // Gets the version number to use for variations seed simulation. Must be called
19 // on a thread where IO is allowed.
20 base::Version GetVersionForSimulation() {
21 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
22 const base::Version installed_version =
23 UpgradeDetectorImpl::GetCurrentlyInstalledVersion();
24 if (installed_version.IsValid())
25 return installed_version;
26 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
27
28 // TODO(asvitkine): Get the version that will be used on restart instead of
29 // the current version on Android, iOS and ChromeOS.
30 return base::Version(version_info::GetVersionNumber());
31 }
32
33 } // namespace
34
10 ChromeVariationsServiceClient::ChromeVariationsServiceClient() {} 35 ChromeVariationsServiceClient::ChromeVariationsServiceClient() {}
11 36
12 ChromeVariationsServiceClient::~ChromeVariationsServiceClient() {} 37 ChromeVariationsServiceClient::~ChromeVariationsServiceClient() {}
13 38
14 std::string ChromeVariationsServiceClient::GetApplicationLocale() { 39 std::string ChromeVariationsServiceClient::GetApplicationLocale() {
15 return g_browser_process->GetApplicationLocale(); 40 return g_browser_process->GetApplicationLocale();
16 } 41 }
17 42
18 base::SequencedWorkerPool* ChromeVariationsServiceClient::GetBlockingPool() { 43 base::SequencedWorkerPool* ChromeVariationsServiceClient::GetBlockingPool() {
19 return content::BrowserThread::GetBlockingPool(); 44 return content::BrowserThread::GetBlockingPool();
20 } 45 }
21 46
47 base::Callback<base::Version(void)>
48 ChromeVariationsServiceClient::GetVersionForSimulationCallback() {
49 return base::Bind(&GetVersionForSimulation);
50 }
51
22 net::URLRequestContextGetter* 52 net::URLRequestContextGetter*
23 ChromeVariationsServiceClient::GetURLRequestContext() { 53 ChromeVariationsServiceClient::GetURLRequestContext() {
24 return g_browser_process->system_request_context(); 54 return g_browser_process->system_request_context();
25 } 55 }
26 56
27 network_time::NetworkTimeTracker* 57 network_time::NetworkTimeTracker*
28 ChromeVariationsServiceClient::GetNetworkTimeTracker() { 58 ChromeVariationsServiceClient::GetNetworkTimeTracker() {
29 return g_browser_process->network_time_tracker(); 59 return g_browser_process->network_time_tracker();
30 } 60 }
31 61
32 void ChromeVariationsServiceClient::OnInitialStartup() { 62 void ChromeVariationsServiceClient::OnInitialStartup() {
33 #if defined(OS_WIN) 63 #if defined(OS_WIN)
34 StartGoogleUpdateRegistrySync(); 64 StartGoogleUpdateRegistrySync();
35 #endif 65 #endif
36 } 66 }
37 67
38 #if defined(OS_WIN) 68 #if defined(OS_WIN)
39 void ChromeVariationsServiceClient::StartGoogleUpdateRegistrySync() { 69 void ChromeVariationsServiceClient::StartGoogleUpdateRegistrySync() {
40 registry_syncer_.RequestRegistrySync(); 70 registry_syncer_.RequestRegistrySync();
41 } 71 }
42 #endif 72 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698