Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: chrome/browser/metrics/variations/variations_service.cc

Issue 147723010: Expose a method in VariationsService to trigger a seed fetch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 // Note that the act of instantiating the scheduler will start the fetch, if 250 // Note that the act of instantiating the scheduler will start the fetch, if
251 // the scheduler deems appropriate. Using Unretained is fine here since the 251 // the scheduler deems appropriate. Using Unretained is fine here since the
252 // lifespan of request_scheduler_ is guaranteed to be shorter than that of 252 // lifespan of request_scheduler_ is guaranteed to be shorter than that of
253 // this service. 253 // this service.
254 request_scheduler_.reset(VariationsRequestScheduler::Create( 254 request_scheduler_.reset(VariationsRequestScheduler::Create(
255 base::Bind(&VariationsService::FetchVariationsSeed, 255 base::Bind(&VariationsService::FetchVariationsSeed,
256 base::Unretained(this)), local_state_)); 256 base::Unretained(this)), local_state_));
257 request_scheduler_->Start(); 257 request_scheduler_->Start();
258 } 258 }
259 259
260 // TODO(rkaplow): Handle this and the similar event in metrics_service by
261 // observing an 'OnAppEnterForeground' event in RequestScheduler instead of
262 // requiring the frontend code to notify each service individually. Since the
263 // scheduler will handle it directly the VariationService shouldn't need to
264 // know details of this anymore.
265 void VariationsService::OnAppEnterForeground() {
266 request_scheduler_->OnAppEnterForeground();
267 }
268
260 // static 269 // static
261 GURL VariationsService::GetVariationsServerURL(PrefService* local_state) { 270 GURL VariationsService::GetVariationsServerURL(PrefService* local_state) {
262 std::string server_url_string(CommandLine::ForCurrentProcess()-> 271 std::string server_url_string(CommandLine::ForCurrentProcess()->
263 GetSwitchValueASCII(switches::kVariationsServerURL)); 272 GetSwitchValueASCII(switches::kVariationsServerURL));
264 if (server_url_string.empty()) 273 if (server_url_string.empty())
265 server_url_string = kDefaultVariationsServerURL; 274 server_url_string = kDefaultVariationsServerURL;
266 GURL server_url = GURL(server_url_string); 275 GURL server_url = GURL(server_url_string);
267 276
268 const std::string restrict_param = GetRestrictParameterPref(local_state); 277 const std::string restrict_param = GetRestrictParameterPref(local_state);
269 if (!restrict_param.empty()) { 278 if (!restrict_param.empty()) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 457
449 void VariationsService::RecordLastFetchTime() { 458 void VariationsService::RecordLastFetchTime() {
450 // local_state_ is NULL in tests, so check it first. 459 // local_state_ is NULL in tests, so check it first.
451 if (local_state_) { 460 if (local_state_) {
452 local_state_->SetInt64(prefs::kVariationsLastFetchTime, 461 local_state_->SetInt64(prefs::kVariationsLastFetchTime,
453 base::Time::Now().ToInternalValue()); 462 base::Time::Now().ToInternalValue());
454 } 463 }
455 } 464 }
456 465
457 } // namespace chrome_variations 466 } // namespace chrome_variations
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698