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

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

Issue 1306913003: Revert of Turn VariationsService::GetVariationsServerURL into instance method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
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"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // value coming from policy prefs. This should be called prior to any calls 102 // value coming from policy prefs. This should be called prior to any calls
103 // to |StartRepeatedVariationsSeedFetch|. 103 // to |StartRepeatedVariationsSeedFetch|.
104 void SetRestrictMode(const std::string& restrict_mode); 104 void SetRestrictMode(const std::string& restrict_mode);
105 105
106 // Exposed for testing. 106 // Exposed for testing.
107 void SetCreateTrialsFromSeedCalledForTesting(bool called); 107 void SetCreateTrialsFromSeedCalledForTesting(bool called);
108 108
109 // Returns the variations server URL, which can vary if a command-line flag is 109 // Returns the variations server URL, which can vary if a command-line flag is
110 // set and/or the variations restrict pref is set in |local_prefs|. Declared 110 // set and/or the variations restrict pref is set in |local_prefs|. Declared
111 // static for test purposes. 111 // static for test purposes.
112 GURL GetVariationsServerURL(PrefService* local_prefs, 112 static GURL GetVariationsServerURL(PrefService* local_prefs,
113 const std::string& restrict_mode_override); 113 const std::string& restrict_mode_override);
114 114
115 // Exposed for testing. 115 // Exposed for testing.
116 static std::string GetDefaultVariationsServerURLForTesting(); 116 static std::string GetDefaultVariationsServerURLForTesting();
117 117
118 // Register Variations related prefs in Local State. 118 // Register Variations related prefs in Local State.
119 static void RegisterPrefs(PrefRegistrySimple* registry); 119 static void RegisterPrefs(PrefRegistrySimple* registry);
120 120
121 // Register Variations related prefs in the Profile prefs. 121 // Register Variations related prefs in the Profile prefs.
122 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 122 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
123 123
124 // Factory method for creating a VariationsService. Does not take ownership of 124 // Factory method for creating a VariationsService. Does not take ownership of
125 // |state_manager|. Caller should ensure that |state_manager| is valid for the 125 // |state_manager|. Caller should ensure that |state_manager| is valid for the
126 // lifetime of this class. 126 // lifetime of this class.
127 static scoped_ptr<VariationsService> Create( 127 static scoped_ptr<VariationsService> Create(
128 scoped_ptr<VariationsServiceClient> client, 128 scoped_ptr<VariationsServiceClient> client,
129 PrefService* local_state, 129 PrefService* local_state,
130 metrics::MetricsStateManager* state_manager, 130 metrics::MetricsStateManager* state_manager,
131 const char* disable_network_switch); 131 const char* disable_network_switch);
132 132
133 // Factory method for creating a VariationsService in a testing context.
134 static scoped_ptr<VariationsService> CreateForTesting(
135 scoped_ptr<VariationsServiceClient> client,
136 PrefService* local_state);
137
138 // Set the PrefService responsible for getting policy-related preferences, 133 // Set the PrefService responsible for getting policy-related preferences,
139 // such as the restrict parameter. 134 // such as the restrict parameter.
140 void set_policy_pref_service(PrefService* service) { 135 void set_policy_pref_service(PrefService* service) {
141 DCHECK(service); 136 DCHECK(service);
142 policy_pref_service_ = service; 137 policy_pref_service_ = service;
143 } 138 }
144 139
145 // Returns the invalid variations seed signature in base64 format, or an empty 140 // Returns the invalid variations seed signature in base64 format, or an empty
146 // string if the signature was valid, missing, or if signature verification is 141 // string if the signature was valid, missing, or if signature verification is
147 // disabled. 142 // disabled.
148 std::string GetInvalidVariationsSeedSignature() const; 143 std::string GetInvalidVariationsSeedSignature() const;
149 144
150 protected: 145 protected:
151 // Starts the fetching process once, where |OnURLFetchComplete| is called with 146 // Starts the fetching process once, where |OnURLFetchComplete| is called with
152 // the response. 147 // the response.
153 virtual void DoActualFetch(); 148 virtual void DoActualFetch();
154 149
155 // Stores the seed to prefs. Set as virtual and protected so that it can be 150 // Stores the seed to prefs. Set as virtual and protected so that it can be
156 // overridden by tests. 151 // overridden by tests.
157 virtual bool StoreSeed(const std::string& seed_data, 152 virtual bool StoreSeed(const std::string& seed_data,
158 const std::string& seed_signature, 153 const std::string& seed_signature,
159 const std::string& country_code, 154 const std::string& country_code,
160 const base::Time& date_fetched, 155 const base::Time& date_fetched,
161 bool is_delta_compressed); 156 bool is_delta_compressed);
162 157
163 // Creates the VariationsService with the given |local_state| prefs service 158 // Creates the VariationsService with the given |local_state| prefs service
164 // and |state_manager|. Does not take ownership of |state_manager|. Caller 159 // and |state_manager|. This instance will take ownership of |notifier|.
165 // should ensure that |state_manager| is valid for the lifetime of this class. 160 // Does not take ownership of |state_manager|. Caller should ensure that
166 // Use the |Create| factory method to create a VariationsService. 161 // |state_manager| is valid for the lifetime of this class. Use the |Create|
167 VariationsService( 162 // factory method to create a VariationsService.
168 scoped_ptr<VariationsServiceClient> client, 163 VariationsService(scoped_ptr<VariationsServiceClient> client,
169 scoped_ptr<web_resource::ResourceRequestAllowedNotifier> notifier, 164 web_resource::ResourceRequestAllowedNotifier* notifier,
170 PrefService* local_state, 165 PrefService* local_state,
171 metrics::MetricsStateManager* state_manager); 166 metrics::MetricsStateManager* state_manager);
172 167
173 private: 168 private:
174 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, Observer); 169 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, Observer);
175 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedStoredWhenOKStatus); 170 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedStoredWhenOKStatus);
176 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedNotStoredWhenNonOKStatus); 171 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedNotStoredWhenNonOKStatus);
177 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedDateUpdatedOn304Status); 172 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedDateUpdatedOn304Status);
178 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, 173 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest,
179 LoadPermanentConsistencyCountry); 174 LoadPermanentConsistencyCountry);
180 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CountryHeader); 175 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CountryHeader);
181 176
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 base::ThreadChecker thread_checker_; 284 base::ThreadChecker thread_checker_;
290 285
291 base::WeakPtrFactory<VariationsService> weak_ptr_factory_; 286 base::WeakPtrFactory<VariationsService> weak_ptr_factory_;
292 287
293 DISALLOW_COPY_AND_ASSIGN(VariationsService); 288 DISALLOW_COPY_AND_ASSIGN(VariationsService);
294 }; 289 };
295 290
296 } // namespace chrome_variations 291 } // namespace chrome_variations
297 292
298 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ 293 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698