| 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" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.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/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/version.h" | 15 #include "base/version.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/metrics/proto/trials_seed.pb.h" | 17 #include "chrome/browser/metrics/proto/trials_seed.pb.h" |
| 18 #include "chrome/browser/prefs/pref_registrar_simple.h" |
| 18 #include "chrome/browser/prefs/pref_service.h" | 19 #include "chrome/browser/prefs/pref_service.h" |
| 19 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/metrics/variations/variations_util.h" | 21 #include "chrome/common/metrics/variations/variations_util.h" |
| 21 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/common/url_fetcher.h" | 24 #include "content/public/common/url_fetcher.h" |
| 24 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
| 25 #include "net/base/load_flags.h" | 26 #include "net/base/load_flags.h" |
| 26 #include "net/base/network_change_notifier.h" | 27 #include "net/base/network_change_notifier.h" |
| 27 #include "net/http/http_response_headers.h" | 28 #include "net/http/http_response_headers.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 154 |
| 154 // Perform the first fetch. | 155 // Perform the first fetch. |
| 155 FetchVariationsSeed(); | 156 FetchVariationsSeed(); |
| 156 | 157 |
| 157 // Repeat this periodically. | 158 // Repeat this periodically. |
| 158 timer_.Start(FROM_HERE, base::TimeDelta::FromHours(kSeedFetchPeriodHours), | 159 timer_.Start(FROM_HERE, base::TimeDelta::FromHours(kSeedFetchPeriodHours), |
| 159 this, &VariationsService::FetchVariationsSeed); | 160 this, &VariationsService::FetchVariationsSeed); |
| 160 } | 161 } |
| 161 | 162 |
| 162 // static | 163 // static |
| 163 void VariationsService::RegisterPrefs(PrefServiceSimple* prefs) { | 164 void VariationsService::RegisterPrefs(PrefRegistrarSimple* prefs) { |
| 164 prefs->RegisterStringPref(prefs::kVariationsSeed, std::string()); | 165 prefs |
| 166 ->RegisterStringPref(prefs::kVariationsSeed, std::string()); |
| 165 prefs->RegisterInt64Pref(prefs::kVariationsSeedDate, | 167 prefs->RegisterInt64Pref(prefs::kVariationsSeedDate, |
| 166 base::Time().ToInternalValue()); | 168 base::Time().ToInternalValue()); |
| 167 } | 169 } |
| 168 | 170 |
| 169 void VariationsService::SetCreateTrialsFromSeedCalledForTesting(bool called) { | 171 void VariationsService::SetCreateTrialsFromSeedCalledForTesting(bool called) { |
| 170 create_trials_from_seed_called_ = called; | 172 create_trials_from_seed_called_ = called; |
| 171 } | 173 } |
| 172 | 174 |
| 173 void VariationsService::DoActualFetch() { | 175 void VariationsService::DoActualFetch() { |
| 174 pending_seed_request_.reset(net::URLFetcher::Create( | 176 pending_seed_request_.reset(net::URLFetcher::Create( |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 variation_id); | 513 variation_id); |
| 512 } | 514 } |
| 513 } | 515 } |
| 514 | 516 |
| 515 trial->SetForced(); | 517 trial->SetForced(); |
| 516 if (IsStudyExpired(study, reference_date)) | 518 if (IsStudyExpired(study, reference_date)) |
| 517 trial->Disable(); | 519 trial->Disable(); |
| 518 } | 520 } |
| 519 | 521 |
| 520 } // namespace chrome_variations | 522 } // namespace chrome_variations |
| OLD | NEW |