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

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

Issue 10381021: Add filtering logic for client-side variations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 8 years, 7 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_SERVICE_H_ 5 #ifndef CHROME_BROWSER_METRICS_VARIATIONS_SERVICE_H_
6 #define CHROME_BROWSER_METRICS_VARIATIONS_SERVICE_H_ 6 #define CHROME_BROWSER_METRICS_VARIATIONS_SERVICE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string>
10
9 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h"
13 #include "base/time.h"
10 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "chrome/browser/metrics/proto/study.pb.h"
11 #include "chrome/browser/metrics/proto/trials_seed.pb.h" 16 #include "chrome/browser/metrics/proto/trials_seed.pb.h"
17 #include "chrome/common/chrome_version_info.h"
12 #include "content/public/common/url_fetcher_delegate.h" 18 #include "content/public/common/url_fetcher_delegate.h"
13 19
14 template <typename T> struct DefaultSingletonTraits; 20 template <typename T> struct DefaultSingletonTraits;
15 class PrefService; 21 class PrefService;
16 22
17 // Used to setup field trials based on stored variations seed data, and fetch 23 // Used to setup field trials based on stored variations seed data, and fetch
18 // new seed data from the variations server. 24 // new seed data from the variations server.
19 class VariationsService : public content::URLFetcherDelegate { 25 class VariationsService : public content::URLFetcherDelegate {
20 public: 26 public:
21 // Returns the singleton instance; 27 // Returns the singleton instance;
(...skipping 11 matching lines...) Expand all
33 39
34 // content::URLFetcherDelegate implementation: 40 // content::URLFetcherDelegate implementation:
35 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; 41 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE;
36 42
37 // Register Variations related prefs in Local State. 43 // Register Variations related prefs in Local State.
38 static void RegisterPrefs(PrefService* prefs); 44 static void RegisterPrefs(PrefService* prefs);
39 45
40 private: 46 private:
41 friend struct DefaultSingletonTraits<VariationsService>; 47 friend struct DefaultSingletonTraits<VariationsService>;
42 48
49 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CheckStudyChannel);
50 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CheckStudyVersion);
51 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CheckStudyVersionWildcards);
52 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CheckStudyDate);
53
43 VariationsService(); 54 VariationsService();
44 55
45 // Store the given seed data to the given local prefs. Note that |seed_data| 56 // 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 57 // 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 58 // will be Base64Encoded for storage. If the string is invalid or the encoding
48 // fails, the |local_prefs| is left as is. 59 // fails, the |local_prefs| is left as is.
49 void StoreSeedData(const std::string& seed_data, PrefService* local_prefs); 60 void StoreSeedData(const std::string& seed_data, PrefService* local_prefs);
50 61
62 // Returns whether |study| should be added to the local field trials list
63 // according to its restriction parameters.
64 static bool ShouldAddStudy(const chrome_variations::Study& study);
65
66 // Checks whether |study| is applicable for the given |channel|.
67 static bool CheckStudyChannel(const chrome_variations::Study& study,
68 chrome::VersionInfo::Channel channel);
69
70 // Checks whether |study| is applicable for the given version string.
71 static bool CheckStudyVersion(const chrome_variations::Study& study,
72 const std::string& version_string);
73
74 // Checks whether |study| is applicable for the given date/time.
75 static bool CheckStudyDate(const chrome_variations::Study& study,
76 const base::Time& date_time);
77
51 // Contains the current seed request. Will only have a value while a request 78 // Contains the current seed request. Will only have a value while a request
52 // is pending, and will be reset by |OnURLFetchComplete|. 79 // is pending, and will be reset by |OnURLFetchComplete|.
53 scoped_ptr<content::URLFetcher> pending_seed_request_; 80 scoped_ptr<content::URLFetcher> pending_seed_request_;
54 81
55 // The variations seed data being used for this session. 82 // 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 83 // 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. 84 // used immediately so it won't need to be stored.
58 chrome_variations::TrialsSeed variations_seed_; 85 chrome_variations::TrialsSeed variations_seed_;
59 }; 86 };
60 87
61 #endif // CHROME_BROWSER_METRICS_VARIATIONS_SERVICE_H_ 88 #endif // CHROME_BROWSER_METRICS_VARIATIONS_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/variations_service.cc » ('j') | chrome/browser/metrics/variations_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698