| 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/build_time.h" | 9 #include "base/build_time.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 // Note that the act of instantiating the scheduler will start the fetch, if | 256 // Note that the act of instantiating the scheduler will start the fetch, if |
| 257 // the scheduler deems appropriate. Using Unretained is fine here since the | 257 // the scheduler deems appropriate. Using Unretained is fine here since the |
| 258 // lifespan of request_scheduler_ is guaranteed to be shorter than that of | 258 // lifespan of request_scheduler_ is guaranteed to be shorter than that of |
| 259 // this service. | 259 // this service. |
| 260 request_scheduler_.reset(VariationsRequestScheduler::Create( | 260 request_scheduler_.reset(VariationsRequestScheduler::Create( |
| 261 base::Bind(&VariationsService::FetchVariationsSeed, | 261 base::Bind(&VariationsService::FetchVariationsSeed, |
| 262 base::Unretained(this)), local_state_)); | 262 base::Unretained(this)), local_state_)); |
| 263 request_scheduler_->Start(); | 263 request_scheduler_->Start(); |
| 264 } | 264 } |
| 265 | 265 |
| 266 // TODO(rkaplow): Handle this and the similar event in metrics_service by |
| 267 // observing an 'OnAppEnterForeground' event in RequestScheduler instead of |
| 268 // requiring the frontend code to notify each service individually. Since the |
| 269 // scheduler will handle it directly the VariationService shouldn't need to |
| 270 // know details of this anymore. |
| 271 void VariationsService::OnAppEnterForeground() { |
| 272 request_scheduler_->OnAppEnterForeground(); |
| 273 } |
| 274 |
| 266 // static | 275 // static |
| 267 GURL VariationsService::GetVariationsServerURL( | 276 GURL VariationsService::GetVariationsServerURL( |
| 268 PrefService* policy_pref_service) { | 277 PrefService* policy_pref_service) { |
| 269 std::string server_url_string(CommandLine::ForCurrentProcess()-> | 278 std::string server_url_string(CommandLine::ForCurrentProcess()-> |
| 270 GetSwitchValueASCII(switches::kVariationsServerURL)); | 279 GetSwitchValueASCII(switches::kVariationsServerURL)); |
| 271 if (server_url_string.empty()) | 280 if (server_url_string.empty()) |
| 272 server_url_string = kDefaultVariationsServerURL; | 281 server_url_string = kDefaultVariationsServerURL; |
| 273 GURL server_url = GURL(server_url_string); | 282 GURL server_url = GURL(server_url_string); |
| 274 | 283 |
| 275 const std::string restrict_param = | 284 const std::string restrict_param = |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 | 478 |
| 470 void VariationsService::RecordLastFetchTime() { | 479 void VariationsService::RecordLastFetchTime() { |
| 471 // local_state_ is NULL in tests, so check it first. | 480 // local_state_ is NULL in tests, so check it first. |
| 472 if (local_state_) { | 481 if (local_state_) { |
| 473 local_state_->SetInt64(prefs::kVariationsLastFetchTime, | 482 local_state_->SetInt64(prefs::kVariationsLastFetchTime, |
| 474 base::Time::Now().ToInternalValue()); | 483 base::Time::Now().ToInternalValue()); |
| 475 } | 484 } |
| 476 } | 485 } |
| 477 | 486 |
| 478 } // namespace chrome_variations | 487 } // namespace chrome_variations |
| OLD | NEW |