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 // This is temporarily disabled for Android. See http://crbug.com/168224 |
| 176 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_ANDROID) |
| 177 // Unless the URL was provided, unsupported builds should return NULL to |
| 178 // indicate that the service should not be used. |
| 179 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 180 switches::kVariationsServerURL)) |
| 181 return NULL; |
| 182 #endif |
| 183 return new VariationsService; |
171 } | 184 } |
172 | 185 |
173 void VariationsService::DoActualFetch() { | 186 void VariationsService::DoActualFetch() { |
174 pending_seed_request_.reset(net::URLFetcher::Create( | 187 pending_seed_request_.reset(net::URLFetcher::Create( |
175 variations_server_url_, net::URLFetcher::GET, this)); | 188 variations_server_url_, net::URLFetcher::GET, this)); |
176 pending_seed_request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 189 pending_seed_request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
177 net::LOAD_DO_NOT_SAVE_COOKIES); | 190 net::LOAD_DO_NOT_SAVE_COOKIES); |
178 pending_seed_request_->SetRequestContext( | 191 pending_seed_request_->SetRequestContext( |
179 g_browser_process->system_request_context()); | 192 g_browser_process->system_request_context()); |
180 pending_seed_request_->SetMaxRetriesOn5xx(kMaxRetrySeedFetch); | 193 pending_seed_request_->SetMaxRetriesOn5xx(kMaxRetrySeedFetch); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 variation_id); | 524 variation_id); |
512 } | 525 } |
513 } | 526 } |
514 | 527 |
515 trial->SetForced(); | 528 trial->SetForced(); |
516 if (IsStudyExpired(study, reference_date)) | 529 if (IsStudyExpired(study, reference_date)) |
517 trial->Disable(); | 530 trial->Disable(); |
518 } | 531 } |
519 | 532 |
520 } // namespace chrome_variations | 533 } // namespace chrome_variations |
OLD | NEW |