| 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 #ifndef CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ |
| 6 #define CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ | 6 #define CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" |
| 13 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #include "chrome/browser/metrics/variations/variations_request_scheduler.h" | 16 #include "chrome/browser/metrics/variations/variations_request_scheduler.h" |
| 16 #include "chrome/browser/metrics/variations/variations_seed_store.h" | 17 #include "chrome/browser/metrics/variations/variations_seed_store.h" |
| 17 #include "chrome/browser/web_resource/resource_request_allowed_notifier.h" | 18 #include "chrome/browser/web_resource/resource_request_allowed_notifier.h" |
| 18 #include "chrome/common/chrome_version_info.h" | 19 #include "chrome/common/chrome_version_info.h" |
| 19 #include "net/url_request/url_fetcher_delegate.h" | 20 #include "net/url_request/url_fetcher_delegate.h" |
| 20 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 21 | 22 |
| 22 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
| 23 #include "chrome/browser/metrics/variations/variations_registry_syncer_win.h" | 24 #include "chrome/browser/metrics/variations/variations_registry_syncer_win.h" |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 26 class PrefService; | 27 class PrefService; |
| 27 class PrefRegistrySimple; | 28 class PrefRegistrySimple; |
| 28 | 29 |
| 29 namespace user_prefs { | 30 namespace base { |
| 30 class PrefRegistrySyncable; | 31 class Version; |
| 31 } | 32 } |
| 32 | 33 |
| 33 namespace metrics { | 34 namespace metrics { |
| 34 class MetricsStateManager; | 35 class MetricsStateManager; |
| 35 } | 36 } |
| 36 | 37 |
| 38 namespace user_prefs { |
| 39 class PrefRegistrySyncable; |
| 40 } |
| 41 |
| 37 namespace chrome_variations { | 42 namespace chrome_variations { |
| 38 | 43 |
| 39 class VariationsSeed; | 44 class VariationsSeed; |
| 40 | 45 |
| 41 // Used to setup field trials based on stored variations seed data, and fetch | 46 // Used to setup field trials based on stored variations seed data, and fetch |
| 42 // new seed data from the variations server. | 47 // new seed data from the variations server. |
| 43 class VariationsService | 48 class VariationsService |
| 44 : public net::URLFetcherDelegate, | 49 : public net::URLFetcherDelegate, |
| 45 public ResourceRequestAllowedNotifier::Observer { | 50 public ResourceRequestAllowedNotifier::Observer { |
| 46 public: | 51 public: |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // Checks if prerequisites for fetching the Variations seed are met, and if | 143 // Checks if prerequisites for fetching the Variations seed are met, and if |
| 139 // so, performs the actual fetch using |DoActualFetch|. | 144 // so, performs the actual fetch using |DoActualFetch|. |
| 140 void FetchVariationsSeed(); | 145 void FetchVariationsSeed(); |
| 141 | 146 |
| 142 // net::URLFetcherDelegate implementation: | 147 // net::URLFetcherDelegate implementation: |
| 143 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 148 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 144 | 149 |
| 145 // ResourceRequestAllowedNotifier::Observer implementation: | 150 // ResourceRequestAllowedNotifier::Observer implementation: |
| 146 virtual void OnResourceRequestsAllowed() OVERRIDE; | 151 virtual void OnResourceRequestsAllowed() OVERRIDE; |
| 147 | 152 |
| 153 // Performs a variations seed simulation with the given |seed| and |version| |
| 154 // and logs the simulation results as histograms. |
| 155 void PerformSimulationWithVersion(scoped_ptr<VariationsSeed> seed, |
| 156 const base::Version& version); |
| 157 |
| 148 // Record the time of the most recent successful fetch. | 158 // Record the time of the most recent successful fetch. |
| 149 void RecordLastFetchTime(); | 159 void RecordLastFetchTime(); |
| 150 | 160 |
| 151 // The pref service used to store persist the variations seed. | 161 // The pref service used to store persist the variations seed. |
| 152 PrefService* local_state_; | 162 PrefService* local_state_; |
| 153 | 163 |
| 154 // Used for instantiating entropy providers for variations seed simulation. | 164 // Used for instantiating entropy providers for variations seed simulation. |
| 155 // Weak pointer. | 165 // Weak pointer. |
| 156 metrics::MetricsStateManager* state_manager_; | 166 metrics::MetricsStateManager* state_manager_; |
| 157 | 167 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 186 | 196 |
| 187 // The start time of the last seed request. This is used to measure the | 197 // The start time of the last seed request. This is used to measure the |
| 188 // latency of seed requests. Initially zero. | 198 // latency of seed requests. Initially zero. |
| 189 base::TimeTicks last_request_started_time_; | 199 base::TimeTicks last_request_started_time_; |
| 190 | 200 |
| 191 #if defined(OS_WIN) | 201 #if defined(OS_WIN) |
| 192 // Helper that handles synchronizing Variations with the Registry. | 202 // Helper that handles synchronizing Variations with the Registry. |
| 193 VariationsRegistrySyncer registry_syncer_; | 203 VariationsRegistrySyncer registry_syncer_; |
| 194 #endif | 204 #endif |
| 195 | 205 |
| 206 base::WeakPtrFactory<VariationsService> weak_ptr_factory_; |
| 207 |
| 196 DISALLOW_COPY_AND_ASSIGN(VariationsService); | 208 DISALLOW_COPY_AND_ASSIGN(VariationsService); |
| 197 }; | 209 }; |
| 198 | 210 |
| 199 } // namespace chrome_variations | 211 } // namespace chrome_variations |
| 200 | 212 |
| 201 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ | 213 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ |
| OLD | NEW |