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

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: 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 PrefRegistrarSimple;
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 VariationsService(); 34 VariationsService();
35 35
36 // This constructor exists for injecting a mock notifier. It is meant for 36 // This constructor exists for injecting a mock notifier. It is meant for
37 // testing only. This instance will take ownership of |notifier|. 37 // testing only. This instance will take ownership of |notifier|.
38 explicit VariationsService(ResourceRequestAllowedNotifier* notifier); 38 explicit VariationsService(ResourceRequestAllowedNotifier* notifier);
39 39
40 virtual ~VariationsService(); 40 virtual ~VariationsService();
41 41
42 // Creates field trials based on Variations Seed loaded from local prefs. If 42 // Creates field trials based on Variations Seed loaded from local prefs. If
43 // there is a problem loading the seed data, all trials specified by the seed 43 // there is a problem loading the seed data, all trials specified by the seed
44 // may not be created. 44 // may not be created.
45 bool CreateTrialsFromSeed(PrefService* local_prefs); 45 bool CreateTrialsFromSeed(PrefService* local_prefs);
46 46
47 // Calls FetchVariationsSeed once and repeats this periodically. See 47 // Calls FetchVariationsSeed once and repeats this periodically. See
48 // implementation for details on the period. Must be called after 48 // implementation for details on the period. Must be called after
49 // |CreateTrialsFromSeed|. 49 // |CreateTrialsFromSeed|.
50 void StartRepeatedVariationsSeedFetch(); 50 void StartRepeatedVariationsSeedFetch();
51 51
52 // Register Variations related prefs in Local State. 52 // Register Variations related prefs in Local State.
53 static void RegisterPrefs(PrefServiceSimple* prefs); 53 static void RegisterPrefs(PrefRegistrarSimple* prefs);
54 54
55 // Exposed for testing. 55 // Exposed for testing.
56 void SetCreateTrialsFromSeedCalledForTesting(bool called); 56 void SetCreateTrialsFromSeedCalledForTesting(bool called);
57 57
58 protected: 58 protected:
59 // Starts the fetching process once, where |OnURLFetchComplete| is called with 59 // Starts the fetching process once, where |OnURLFetchComplete| is called with
60 // the response. 60 // the response.
61 virtual void DoActualFetch(); 61 virtual void DoActualFetch();
62 62
63 private: 63 private:
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 scoped_ptr<ResourceRequestAllowedNotifier> resource_request_allowed_notifier_; 164 scoped_ptr<ResourceRequestAllowedNotifier> resource_request_allowed_notifier_;
165 165
166 // The start time of the last seed request. This is used to measure the 166 // The start time of the last seed request. This is used to measure the
167 // latency of seed requests. Initially zero. 167 // latency of seed requests. Initially zero.
168 base::TimeTicks last_request_started_time_; 168 base::TimeTicks last_request_started_time_;
169 }; 169 };
170 170
171 } // namespace chrome_variations 171 } // namespace chrome_variations
172 172
173 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ 173 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698