OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_METRICS_VARIATIONS_SERVICE_H_ | |
6 #define CHROME_BROWSER_METRICS_VARIATIONS_SERVICE_H_ | |
7 #pragma once | |
8 | |
9 #include "base/compiler_specific.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "chrome/browser/metrics/proto/trials_seed.pb.h" | |
12 #include "content/public/common/url_fetcher_delegate.h" | |
13 | |
14 template <typename T> struct DefaultSingletonTraits; | |
15 class PrefService; | |
16 | |
17 // Used to setup field trials based on stored variations seed data, and fetch | |
18 // new seed data from the variations server. | |
19 class VariationsService : public content::URLFetcherDelegate { | |
20 public: | |
21 // Returns the singleton instance; | |
22 static VariationsService* GetInstance(); | |
23 | |
24 virtual ~VariationsService(); | |
25 | |
MAD
2012/05/04 23:09:07
Please privatize the destructor or too...
jwd
2012/05/07 13:09:57
Done.
| |
26 // Loads the Variations seed data from the given local prefs. If there is a | |
27 // problem with loading, the pref value is cleared. | |
28 void LoadVariationsSeed(PrefService* local_prefs); | |
29 | |
30 // Starts the fetching process, where |OnURLFetchComplete| is called with the | |
31 // response. | |
32 void StartFetchingVariationsSeed(); | |
33 | |
34 // content::URLFetcherDelegate implementation: | |
35 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; | |
36 | |
37 // Register Variations related prefs in Local State. | |
38 static void RegisterPrefs(PrefService* prefs); | |
39 | |
40 private: | |
41 friend struct DefaultSingletonTraits<VariationsService>; | |
42 | |
43 VariationsService(); | |
44 | |
45 // Store the given seed data to the given local prefs. Note that |seed_data| | |
46 // is assumed to be the raw serialized protobuf data stored in a string. It | |
47 // will be Base64Encoded for storage. If the string is invalid or the encoding | |
48 // fails, the |local_prefs| is left as is. | |
49 void StoreSeedData(const std::string& seed_data, PrefService* local_prefs); | |
50 | |
51 // Contains the current seed request. Will only have a value while a request | |
52 // is pending, and will be reset by |OnURLFetchComplete|. | |
53 scoped_ptr<content::URLFetcher> pending_seed_request_; | |
54 | |
55 // The variations seed data being used for this session. | |
56 // TODO(jwd): This should be removed. When the seed data is loaded, it will be | |
57 // used immediately so it won't need to be stored. | |
58 chrome_variations::TrialsSeed variations_seed_; | |
59 }; | |
60 | |
61 #endif // CHROME_BROWSER_METRICS_VARIATIONS_SERVICE_H_ | |
OLD | NEW |