| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_request_scheduler_mobile.
h" | 5 #include "chrome/browser/metrics/variations/variations_request_scheduler_mobile.
h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/common/pref_names.h" | 8 #include "chrome/common/pref_names.h" |
| 9 | 9 |
| 10 namespace chrome_variations { | 10 namespace chrome_variations { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 // Time before attempting a seed fetch after a ScheduleFetch(), in seconds. |
| 15 const int kScheduleFetchDelaySeconds = 5; |
| 16 |
| 14 // Time between seed fetches, in hours. | 17 // Time between seed fetches, in hours. |
| 15 const int kSeedFetchPeriodHours = 5; | 18 const int kSeedFetchPeriodHours = 5; |
| 16 | 19 |
| 17 } // namespace | 20 } // namespace |
| 18 | 21 |
| 19 VariationsRequestSchedulerMobile::VariationsRequestSchedulerMobile( | 22 VariationsRequestSchedulerMobile::VariationsRequestSchedulerMobile( |
| 20 const base::Closure& task, | 23 const base::Closure& task, |
| 21 PrefService* local_state) : | 24 PrefService* local_state) : |
| 22 VariationsRequestScheduler(task), local_state_(local_state) { | 25 VariationsRequestScheduler(task), local_state_(local_state) { |
| 23 } | 26 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 34 local_state_->GetInt64(prefs::kVariationsLastFetchTime)); | 37 local_state_->GetInt64(prefs::kVariationsLastFetchTime)); |
| 35 if (base::Time::Now() > | 38 if (base::Time::Now() > |
| 36 last_fetch_time + base::TimeDelta::FromHours(kSeedFetchPeriodHours)) { | 39 last_fetch_time + base::TimeDelta::FromHours(kSeedFetchPeriodHours)) { |
| 37 task().Run(); | 40 task().Run(); |
| 38 } | 41 } |
| 39 } | 42 } |
| 40 | 43 |
| 41 void VariationsRequestSchedulerMobile::Reset() { | 44 void VariationsRequestSchedulerMobile::Reset() { |
| 42 } | 45 } |
| 43 | 46 |
| 47 void VariationsRequestSchedulerMobile::ScheduleFetch() { |
| 48 // Since Start() launches a one-off execution, we can reuse it here. Also |
| 49 // note that since Start() verifies that the seed needs to be refreshed, we |
| 50 // do not verify here. |
| 51 schedule_fetch_timer_.Start( |
| 52 FROM_HERE, |
| 53 base::TimeDelta::FromSeconds(kScheduleFetchDelaySeconds), |
| 54 this, |
| 55 &VariationsRequestSchedulerMobile::Start); |
| 56 } |
| 57 |
| 44 // static | 58 // static |
| 45 VariationsRequestScheduler* VariationsRequestScheduler::Create( | 59 VariationsRequestScheduler* VariationsRequestScheduler::Create( |
| 46 const base::Closure& task, | 60 const base::Closure& task, |
| 47 PrefService* local_state) { | 61 PrefService* local_state) { |
| 48 return new VariationsRequestSchedulerMobile(task, local_state); | 62 return new VariationsRequestSchedulerMobile(task, local_state); |
| 49 } | 63 } |
| 50 | 64 |
| 51 } // namespace chrome_variations | 65 } // namespace chrome_variations |
| OLD | NEW |