OLD | NEW |
---|---|
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 #include "chrome/browser/metrics/variations/variations_service.h" | 5 #include "chrome/browser/metrics/variations/variations_service.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/build_time.h" | 10 #include "base/build_time.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 DCHECK(create_trials_from_seed_called_); | 152 DCHECK(create_trials_from_seed_called_); |
153 | 153 |
154 // Perform the first fetch. | 154 // Perform the first fetch. |
155 FetchVariationsSeed(); | 155 FetchVariationsSeed(); |
156 | 156 |
157 // Repeat this periodically. | 157 // Repeat this periodically. |
158 timer_.Start(FROM_HERE, base::TimeDelta::FromHours(kSeedFetchPeriodHours), | 158 timer_.Start(FROM_HERE, base::TimeDelta::FromHours(kSeedFetchPeriodHours), |
159 this, &VariationsService::FetchVariationsSeed); | 159 this, &VariationsService::FetchVariationsSeed); |
160 } | 160 } |
161 | 161 |
162 void VariationsService::SetCreateTrialsFromSeedCalledForTesting(bool called) { | |
163 create_trials_from_seed_called_ = called; | |
164 } | |
165 | |
162 // static | 166 // static |
163 void VariationsService::RegisterPrefs(PrefServiceSimple* prefs) { | 167 void VariationsService::RegisterPrefs(PrefServiceSimple* prefs) { |
164 prefs->RegisterStringPref(prefs::kVariationsSeed, std::string()); | 168 prefs->RegisterStringPref(prefs::kVariationsSeed, std::string()); |
165 prefs->RegisterInt64Pref(prefs::kVariationsSeedDate, | 169 prefs->RegisterInt64Pref(prefs::kVariationsSeedDate, |
166 base::Time().ToInternalValue()); | 170 base::Time().ToInternalValue()); |
167 } | 171 } |
168 | 172 |
169 void VariationsService::SetCreateTrialsFromSeedCalledForTesting(bool called) { | 173 // static |
170 create_trials_from_seed_called_ = called; | 174 VariationsService* VariationsService::Create() { |
175 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_ANDROID) | |
Alexei Svitkine (slow)
2013/01/03 20:14:06
Do we have a bug tracking the !ANDROID part? If so
SteveT
2013/01/03 20:35:42
Done.
| |
176 // Unless the URL was provided, unsupported builds should return NULL to | |
Alexei Svitkine (slow)
2013/01/03 20:14:06
I think "unofficial" is the correct term.
SteveT
2013/01/03 20:35:42
So I originally used unofficial, but I changed the
Alexei Svitkine (slow)
2013/01/03 20:40:42
Ah, makes sense. OK.
| |
177 // indicate that the service should not be used. | |
178 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
179 switches::kVariationsServerURL)) | |
180 return NULL; | |
181 #endif | |
182 return new VariationsService; | |
171 } | 183 } |
172 | 184 |
173 void VariationsService::DoActualFetch() { | 185 void VariationsService::DoActualFetch() { |
174 pending_seed_request_.reset(net::URLFetcher::Create( | 186 pending_seed_request_.reset(net::URLFetcher::Create( |
175 variations_server_url_, net::URLFetcher::GET, this)); | 187 variations_server_url_, net::URLFetcher::GET, this)); |
176 pending_seed_request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 188 pending_seed_request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
177 net::LOAD_DO_NOT_SAVE_COOKIES); | 189 net::LOAD_DO_NOT_SAVE_COOKIES); |
178 pending_seed_request_->SetRequestContext( | 190 pending_seed_request_->SetRequestContext( |
179 g_browser_process->system_request_context()); | 191 g_browser_process->system_request_context()); |
180 pending_seed_request_->SetMaxRetriesOn5xx(kMaxRetrySeedFetch); | 192 pending_seed_request_->SetMaxRetriesOn5xx(kMaxRetrySeedFetch); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
511 variation_id); | 523 variation_id); |
512 } | 524 } |
513 } | 525 } |
514 | 526 |
515 trial->SetForced(); | 527 trial->SetForced(); |
516 if (IsStudyExpired(study, reference_date)) | 528 if (IsStudyExpired(study, reference_date)) |
517 trial->Disable(); | 529 trial->Disable(); |
518 } | 530 } |
519 | 531 |
520 } // namespace chrome_variations | 532 } // namespace chrome_variations |
OLD | NEW |