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

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

Issue 10917120: Activate the VariationsService for ChromeOS and ensure that it does not ping the server until the E… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: nikita nits Created 8 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"
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/common/chrome_version_info.h" 18 #include "chrome/common/chrome_version_info.h"
19 #include "googleurl/src/gurl.h" 19 #include "googleurl/src/gurl.h"
20 #include "net/base/network_change_notifier.h" 20 #include "net/base/network_change_notifier.h"
21 #include "net/url_request/url_fetcher_delegate.h" 21 #include "net/url_request/url_fetcher_delegate.h"
22 22
23 #if defined(OS_CHROMEOS)
24 #include "chrome/browser/chromeos/login/wizard_controller.h"
25 #endif
26
23 class PrefService; 27 class PrefService;
24 28
25 namespace chrome_variations { 29 namespace chrome_variations {
26 30
27 // Used to setup field trials based on stored variations seed data, and fetch 31 // Used to setup field trials based on stored variations seed data, and fetch
28 // new seed data from the variations server. 32 // new seed data from the variations server.
29 class VariationsService 33 class VariationsService
30 : public net::URLFetcherDelegate, 34 : public net::URLFetcherDelegate,
31 public net::NetworkChangeNotifier::ConnectionTypeObserver{ 35 #if defined(OS_CHROMEOS)
36 public chromeos::WizardController::Observer,
37 #endif
38 public net::NetworkChangeNotifier::ConnectionTypeObserver {
32 public: 39 public:
33 VariationsService(); 40 VariationsService();
34 virtual ~VariationsService(); 41 virtual ~VariationsService();
35 42
36 // Creates field trials based on Variations Seed loaded from local prefs. If 43 // 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 44 // there is a problem loading the seed data, all trials specified by the seed
38 // may not be created. 45 // may not be created.
39 bool CreateTrialsFromSeed(PrefService* local_prefs); 46 bool CreateTrialsFromSeed(PrefService* local_prefs);
40 47
41 // Calls FetchVariationsSeed once and repeats this periodically. See 48 // Calls FetchVariationsSeed once and repeats this periodically. See
42 // implementation for details on the period. Must be called after 49 // implementation for details on the period. Must be called after
43 // |CreateTrialsFromSeed|. 50 // |CreateTrialsFromSeed|.
44 void StartRepeatedVariationsSeedFetch(); 51 void StartRepeatedVariationsSeedFetch();
45 52
46 // Starts the fetching process once, where |OnURLFetchComplete| is called with 53 // Starts the fetching process once, where |OnURLFetchComplete| is called with
47 // the response. If the network is down at the time, sets a flag to retry when 54 // the response. If the network is down at the time, sets a flag to retry when
48 // the network is back online. This is virtual so it can be overriden for 55 // the network is back online. This is virtual so it can be overriden for
49 // testing. 56 // testing.
50 virtual void FetchVariationsSeed(); 57 virtual void FetchVariationsSeed();
51 58
52 // Exposed for testing. 59 // Exposed for testing.
53 void SetWasOfflineDuringLastRequestAttemptForTesting(bool offline); 60 void SetWasOfflineDuringLastRequestAttemptForTesting(bool offline);
54 61
62 #if defined(OS_CHROMEOS)
63 // chromeos::WizardController::Observer implementation:
64 virtual void OnScreenChanged(chromeos::WizardScreen* next_screen) OVERRIDE;
65
66 virtual void OnSessionStart() OVERRIDE;
Alexei Svitkine (slow) 2012/09/10 16:50:11 Remove empty lines between these functions.
SteveT 2012/09/10 19:33:52 Done.
67
68 virtual void OnEulaAccepted() OVERRIDE;
69 #endif
70
55 // Register Variations related prefs in Local State. 71 // Register Variations related prefs in Local State.
56 static void RegisterPrefs(PrefService* prefs); 72 static void RegisterPrefs(PrefService* prefs);
57 73
58 private: 74 private:
59 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CheckStudyChannel); 75 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CheckStudyChannel);
60 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CheckStudyLocale); 76 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CheckStudyLocale);
61 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CheckStudyPlatform); 77 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CheckStudyPlatform);
62 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CheckStudyVersion); 78 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CheckStudyVersion);
63 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CheckStudyVersionWildcards); 79 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CheckStudyVersionWildcards);
64 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CheckStudyStartDate); 80 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CheckStudyStartDate);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // The URL to use for querying the Variations server. 155 // The URL to use for querying the Variations server.
140 GURL variations_server_url_; 156 GURL variations_server_url_;
141 157
142 // Cached serial number from the most recently fetched Variations seed. 158 // Cached serial number from the most recently fetched Variations seed.
143 std::string variations_serial_number_; 159 std::string variations_serial_number_;
144 160
145 // Tracks whether |CreateTrialsFromSeed| has been called, to ensure that 161 // Tracks whether |CreateTrialsFromSeed| has been called, to ensure that
146 // it gets called prior to |StartRepeatedVariationsSeedFetch|. 162 // it gets called prior to |StartRepeatedVariationsSeedFetch|.
147 bool create_trials_from_seed_called_; 163 bool create_trials_from_seed_called_;
148 164
165 #if defined(OS_CHROMEOS)
166 // Tracks whether or not the service is waiting for the user to accept the
167 // EULA before performing the next request.
168 bool waiting_for_user_to_accept_eula_;
169 #endif
170
149 // Tracks whether or not the last seed request attempt failed due to being 171 // Tracks whether or not the last seed request attempt failed due to being
150 // offline. 172 // offline.
151 bool was_offline_during_last_request_attempt_; 173 bool was_offline_during_last_request_attempt_;
152 174
153 // The timer used to repeatedly ping the server. Keep this as an instance 175 // The timer used to repeatedly ping the server. Keep this as an instance
154 // member so if VariationsService goes out of scope, the timer is 176 // member so if VariationsService goes out of scope, the timer is
155 // automatically canceled. 177 // automatically canceled.
156 base::RepeatingTimer<VariationsService> timer_; 178 base::RepeatingTimer<VariationsService> timer_;
157 }; 179 };
158 180
159 } // namespace chrome_variations 181 } // namespace chrome_variations
160 182
161 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ 183 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698