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

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

Issue 11741003: Remove PrefServiceSimple, replacing it with PrefService and PrefRegistrySimple. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Switch to desired interfaces. Created 7 years, 11 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 | Annotate | Revision Log
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 #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/metrics/field_trial.h" 13 #include "base/metrics/field_trial.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "base/timer.h" 15 #include "base/timer.h"
16 #include "chrome/browser/metrics/proto/study.pb.h" 16 #include "chrome/browser/metrics/proto/study.pb.h"
17 #include "chrome/browser/metrics/proto/trials_seed.pb.h" 17 #include "chrome/browser/metrics/proto/trials_seed.pb.h"
18 #include "chrome/browser/metrics/variations/resource_request_allowed_notifier.h" 18 #include "chrome/browser/metrics/variations/resource_request_allowed_notifier.h"
19 #include "chrome/common/chrome_version_info.h" 19 #include "chrome/common/chrome_version_info.h"
20 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
21 #include "net/url_request/url_fetcher_delegate.h" 21 #include "net/url_request/url_fetcher_delegate.h"
22 22
23 class PrefService; 23 class PrefService;
24 class PrefServiceSimple; 24 class PrefRegistrySimple;
25 25
26 namespace chrome_variations { 26 namespace chrome_variations {
27 27
28 // Used to setup field trials based on stored variations seed data, and fetch 28 // Used to setup field trials based on stored variations seed data, and fetch
29 // new seed data from the variations server. 29 // new seed data from the variations server.
30 class VariationsService 30 class VariationsService
31 : public net::URLFetcherDelegate, 31 : public net::URLFetcherDelegate,
32 public ResourceRequestAllowedNotifier::Observer { 32 public ResourceRequestAllowedNotifier::Observer {
33 public: 33 public:
34 virtual ~VariationsService(); 34 virtual ~VariationsService();
35 35
36 // Creates field trials based on Variations Seed loaded from local prefs. If 36 // Creates field trials based on Variations Seed loaded from local prefs. If
37 // there is a problem loading the seed data, all trials specified by the seed 37 // there is a problem loading the seed data, all trials specified by the seed
38 // may not be created. 38 // may not be created.
39 bool CreateTrialsFromSeed(PrefService* local_prefs); 39 bool CreateTrialsFromSeed(PrefService* local_prefs);
40 40
41 // Calls FetchVariationsSeed once and repeats this periodically. See 41 // Calls FetchVariationsSeed once and repeats this periodically. See
42 // implementation for details on the period. Must be called after 42 // implementation for details on the period. Must be called after
43 // |CreateTrialsFromSeed|. 43 // |CreateTrialsFromSeed|.
44 void StartRepeatedVariationsSeedFetch(); 44 void StartRepeatedVariationsSeedFetch();
45 45
46 // Exposed for testing. 46 // Exposed for testing.
47 void SetCreateTrialsFromSeedCalledForTesting(bool called); 47 void SetCreateTrialsFromSeedCalledForTesting(bool called);
48 48
49 // Register Variations related prefs in Local State. 49 // Register Variations related prefs in Local State.
50 static void RegisterPrefs(PrefServiceSimple* prefs); 50 static void RegisterPrefs(PrefRegistrySimple* prefs);
51 51
52 // Factory method for creating a VariationsService. 52 // Factory method for creating a VariationsService.
53 static VariationsService* Create(); 53 static VariationsService* Create();
54 54
55 protected: 55 protected:
56 // Starts the fetching process once, where |OnURLFetchComplete| is called with 56 // Starts the fetching process once, where |OnURLFetchComplete| is called with
57 // the response. 57 // the response.
58 virtual void DoActualFetch(); 58 virtual void DoActualFetch();
59 59
60 // This constructor exists for injecting a mock notifier. It is meant for 60 // This constructor exists for injecting a mock notifier. It is meant for
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 scoped_ptr<ResourceRequestAllowedNotifier> resource_request_allowed_notifier_; 171 scoped_ptr<ResourceRequestAllowedNotifier> resource_request_allowed_notifier_;
172 172
173 // The start time of the last seed request. This is used to measure the 173 // The start time of the last seed request. This is used to measure the
174 // latency of seed requests. Initially zero. 174 // latency of seed requests. Initially zero.
175 base::TimeTicks last_request_started_time_; 175 base::TimeTicks last_request_started_time_;
176 }; 176 };
177 177
178 } // namespace chrome_variations 178 } // namespace chrome_variations
179 179
180 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ 180 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698