| 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_service.h" | 5 #include "chrome/browser/metrics/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/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
| 13 #include "base/version.h" | 13 #include "base/version.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/metrics/proto/trials_seed.pb.h" | 15 #include "chrome/browser/metrics/proto/trials_seed.pb.h" |
| 16 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
| 17 #include "chrome/common/metrics/experiments_helper.h" | 17 #include "chrome/common/metrics/experiments_helper.h" |
| 18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 19 #include "content/public/common/url_fetcher.h" | |
| 20 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 21 #include "net/base/load_flags.h" | 20 #include "net/base/load_flags.h" |
| 22 #include "net/base/network_change_notifier.h" | 21 #include "net/base/network_change_notifier.h" |
| 23 #include "net/http/http_response_headers.h" | 22 #include "net/http/http_response_headers.h" |
| 23 #include "net/url_request/url_fetcher.h" |
| 24 #include "net/url_request/url_request_status.h" | 24 #include "net/url_request/url_request_status.h" |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // Default server of Variations seed info. | 28 // Default server of Variations seed info. |
| 29 const char kDefaultVariationsServer[] = | 29 const char kDefaultVariationsServer[] = |
| 30 "https://clients4.google.com/chrome-variations/seed"; | 30 "https://clients4.google.com/chrome-variations/seed"; |
| 31 const int kMaxRetrySeedFetch = 5; | 31 const int kMaxRetrySeedFetch = 5; |
| 32 | 32 |
| 33 // Maps chrome_variations::Study_Channel enum values to corresponding | 33 // Maps chrome_variations::Study_Channel enum values to corresponding |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 CreateTrialFromStudy(seed.study(i), reference_date); | 100 CreateTrialFromStudy(seed.study(i), reference_date); |
| 101 } | 101 } |
| 102 | 102 |
| 103 return true; | 103 return true; |
| 104 } | 104 } |
| 105 | 105 |
| 106 void VariationsService::StartFetchingVariationsSeed() { | 106 void VariationsService::StartFetchingVariationsSeed() { |
| 107 if (net::NetworkChangeNotifier::IsOffline()) | 107 if (net::NetworkChangeNotifier::IsOffline()) |
| 108 return; | 108 return; |
| 109 | 109 |
| 110 pending_seed_request_.reset(content::URLFetcher::Create( | 110 pending_seed_request_.reset(net::URLFetcher::Create( |
| 111 GURL(kDefaultVariationsServer), net::URLFetcher::GET, this)); | 111 GURL(kDefaultVariationsServer), net::URLFetcher::GET, this)); |
| 112 pending_seed_request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 112 pending_seed_request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 113 net::LOAD_DO_NOT_SAVE_COOKIES); | 113 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 114 pending_seed_request_->SetRequestContext( | 114 pending_seed_request_->SetRequestContext( |
| 115 g_browser_process->system_request_context()); | 115 g_browser_process->system_request_context()); |
| 116 pending_seed_request_->SetMaxRetries(kMaxRetrySeedFetch); | 116 pending_seed_request_->SetMaxRetries(kMaxRetrySeedFetch); |
| 117 pending_seed_request_->Start(); | 117 pending_seed_request_->Start(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void VariationsService::OnURLFetchComplete(const net::URLFetcher* source) { | 120 void VariationsService::OnURLFetchComplete(const net::URLFetcher* source) { |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 experiments_helper::AssociateGoogleVariationIDForce(study.name(), | 373 experiments_helper::AssociateGoogleVariationIDForce(study.name(), |
| 374 experiment.name(), | 374 experiment.name(), |
| 375 variation_id); | 375 variation_id); |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 | 378 |
| 379 trial->SetForced(); | 379 trial->SetForced(); |
| 380 if (IsStudyExpired(study, reference_date)) | 380 if (IsStudyExpired(study, reference_date)) |
| 381 trial->Disable(); | 381 trial->Disable(); |
| 382 } | 382 } |
| OLD | NEW |