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