OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/background_sync/background_sync_controller_impl.h" | 5 #include "chrome/browser/background_sync/background_sync_controller_impl.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 const char BackgroundSyncControllerImpl::kFieldTrialName[] = "BackgroundSync"; | 21 const char BackgroundSyncControllerImpl::kFieldTrialName[] = "BackgroundSync"; |
22 const char BackgroundSyncControllerImpl::kDisabledParameterName[] = "disabled"; | 22 const char BackgroundSyncControllerImpl::kDisabledParameterName[] = "disabled"; |
23 const char BackgroundSyncControllerImpl::kMaxAttemptsParameterName[] = | 23 const char BackgroundSyncControllerImpl::kMaxAttemptsParameterName[] = |
24 "max_sync_attempts"; | 24 "max_sync_attempts"; |
25 const char BackgroundSyncControllerImpl::kInitialRetryParameterName[] = | 25 const char BackgroundSyncControllerImpl::kInitialRetryParameterName[] = |
26 "initial_retry_delay_mins"; | 26 "initial_retry_delay_mins"; |
27 const char BackgroundSyncControllerImpl::kRetryDelayFactorParameterName[] = | 27 const char BackgroundSyncControllerImpl::kRetryDelayFactorParameterName[] = |
28 "retry_delay_factor"; | 28 "retry_delay_factor"; |
29 const char BackgroundSyncControllerImpl::kMinSyncRecoveryTimeName[] = | 29 const char BackgroundSyncControllerImpl::kMinSyncRecoveryTimeName[] = |
30 "min_recovery_time_ms"; | 30 "min_recovery_time_ms"; |
31 const char BackgroundSyncControllerImpl::kMaxSyncEventDuration[] = | |
32 "max_sync_event_duration_sec"; | |
31 | 33 |
32 BackgroundSyncControllerImpl::BackgroundSyncControllerImpl(Profile* profile) | 34 BackgroundSyncControllerImpl::BackgroundSyncControllerImpl(Profile* profile) |
33 : profile_(profile) {} | 35 : profile_(profile) {} |
34 | 36 |
35 BackgroundSyncControllerImpl::~BackgroundSyncControllerImpl() = default; | 37 BackgroundSyncControllerImpl::~BackgroundSyncControllerImpl() = default; |
36 | 38 |
37 void BackgroundSyncControllerImpl::GetParameterOverrides( | 39 void BackgroundSyncControllerImpl::GetParameterOverrides( |
38 content::BackgroundSyncParameters* parameters) const { | 40 content::BackgroundSyncParameters* parameters) const { |
39 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 41 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
40 | 42 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 | 76 |
75 if (ContainsKey(field_params, kMinSyncRecoveryTimeName)) { | 77 if (ContainsKey(field_params, kMinSyncRecoveryTimeName)) { |
76 int64_t min_sync_recovery_time_ms; | 78 int64_t min_sync_recovery_time_ms; |
77 if (base::StringToInt64(field_params[kMinSyncRecoveryTimeName], | 79 if (base::StringToInt64(field_params[kMinSyncRecoveryTimeName], |
78 &min_sync_recovery_time_ms)) { | 80 &min_sync_recovery_time_ms)) { |
79 parameters->min_sync_recovery_time = | 81 parameters->min_sync_recovery_time = |
80 base::TimeDelta::FromMilliseconds(min_sync_recovery_time_ms); | 82 base::TimeDelta::FromMilliseconds(min_sync_recovery_time_ms); |
81 } | 83 } |
82 } | 84 } |
83 | 85 |
86 if (ContainsKey(field_params, kMaxSyncEventDuration)) { | |
87 int64_t max_sync_event_duration_sec; | |
88 if (base::StringToInt64(field_params[kMaxSyncEventDuration], | |
iclelland
2015/12/21 19:50:15
I think this should be StringToInt (and `int max_s
jkarlin
2015/12/28 15:51:29
Done.
| |
89 &max_sync_event_duration_sec)) { | |
90 parameters->max_sync_event_duration = | |
91 base::TimeDelta::FromSeconds(max_sync_event_duration_sec); | |
92 } | |
93 } | |
94 | |
84 return; | 95 return; |
85 } | 96 } |
86 | 97 |
87 void BackgroundSyncControllerImpl::NotifyBackgroundSyncRegistered( | 98 void BackgroundSyncControllerImpl::NotifyBackgroundSyncRegistered( |
88 const GURL& origin) { | 99 const GURL& origin) { |
89 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 100 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
90 DCHECK_EQ(origin, origin.GetOrigin()); | 101 DCHECK_EQ(origin, origin.GetOrigin()); |
91 | 102 |
92 if (profile_->IsOffTheRecord()) | 103 if (profile_->IsOffTheRecord()) |
93 return; | 104 return; |
(...skipping 12 matching lines...) Expand all Loading... | |
106 BackgroundSyncLauncherAndroid::LaunchBrowserIfStopped(enabled, min_ms); | 117 BackgroundSyncLauncherAndroid::LaunchBrowserIfStopped(enabled, min_ms); |
107 #else | 118 #else |
108 // TODO(jkarlin): Use BackgroundModeManager to enter background mode. See | 119 // TODO(jkarlin): Use BackgroundModeManager to enter background mode. See |
109 // https://crbug.com/484201. | 120 // https://crbug.com/484201. |
110 #endif | 121 #endif |
111 } | 122 } |
112 | 123 |
113 rappor::RapporService* BackgroundSyncControllerImpl::GetRapporService() { | 124 rappor::RapporService* BackgroundSyncControllerImpl::GetRapporService() { |
114 return g_browser_process->rappor_service(); | 125 return g_browser_process->rappor_service(); |
115 } | 126 } |
OLD | NEW |