| 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_registry_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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 void VariationsService::StartGoogleUpdateRegistrySync() { | 192 void VariationsService::StartGoogleUpdateRegistrySync() { |
| 192 registry_syncer_.RequestRegistrySync(); | 193 registry_syncer_.RequestRegistrySync(); |
| 193 } | 194 } |
| 194 #endif | 195 #endif |
| 195 | 196 |
| 196 void VariationsService::SetCreateTrialsFromSeedCalledForTesting(bool called) { | 197 void VariationsService::SetCreateTrialsFromSeedCalledForTesting(bool called) { |
| 197 create_trials_from_seed_called_ = called; | 198 create_trials_from_seed_called_ = called; |
| 198 } | 199 } |
| 199 | 200 |
| 200 // static | 201 // static |
| 201 void VariationsService::RegisterPrefs(PrefServiceSimple* prefs) { | 202 void VariationsService::RegisterPrefs(PrefRegistrySimple* registry) { |
| 202 prefs->RegisterStringPref(prefs::kVariationsSeed, std::string()); | 203 registry->RegisterStringPref(prefs::kVariationsSeed, std::string()); |
| 203 prefs->RegisterInt64Pref(prefs::kVariationsSeedDate, | 204 registry->RegisterInt64Pref(prefs::kVariationsSeedDate, |
| 204 base::Time().ToInternalValue()); | 205 base::Time().ToInternalValue()); |
| 205 } | 206 } |
| 206 | 207 |
| 207 // static | 208 // static |
| 208 VariationsService* VariationsService::Create() { | 209 VariationsService* VariationsService::Create() { |
| 209 // This is temporarily disabled for Android. See http://crbug.com/168224 | 210 // This is temporarily disabled for Android. See http://crbug.com/168224 |
| 210 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_ANDROID) | 211 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_ANDROID) |
| 211 // Unless the URL was provided, unsupported builds should return NULL to | 212 // Unless the URL was provided, unsupported builds should return NULL to |
| 212 // indicate that the service should not be used. | 213 // indicate that the service should not be used. |
| 213 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 214 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 214 switches::kVariationsServerURL)) | 215 switches::kVariationsServerURL)) |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 variation_id); | 560 variation_id); |
| 560 } | 561 } |
| 561 } | 562 } |
| 562 | 563 |
| 563 trial->SetForced(); | 564 trial->SetForced(); |
| 564 if (IsStudyExpired(study, reference_date)) | 565 if (IsStudyExpired(study, reference_date)) |
| 565 trial->Disable(); | 566 trial->Disable(); |
| 566 } | 567 } |
| 567 | 568 |
| 568 } // namespace chrome_variations | 569 } // namespace chrome_variations |
| OLD | NEW |