| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 std::map<std::string, std::string> field_params; | 48 std::map<std::string, std::string> field_params; |
| 49 if (!variations::GetVariationParams(kFieldTrialName, &field_params)) | 49 if (!variations::GetVariationParams(kFieldTrialName, &field_params)) |
| 50 return; | 50 return; |
| 51 | 51 |
| 52 if (base::LowerCaseEqualsASCII(field_params[kDisabledParameterName], | 52 if (base::LowerCaseEqualsASCII(field_params[kDisabledParameterName], |
| 53 "true")) { | 53 "true")) { |
| 54 parameters->disable = true; | 54 parameters->disable = true; |
| 55 } | 55 } |
| 56 | 56 |
| 57 if (ContainsKey(field_params, kMaxAttemptsParameterName)) { | 57 if (base::ContainsKey(field_params, kMaxAttemptsParameterName)) { |
| 58 int max_attempts; | 58 int max_attempts; |
| 59 if (base::StringToInt(field_params[kMaxAttemptsParameterName], | 59 if (base::StringToInt(field_params[kMaxAttemptsParameterName], |
| 60 &max_attempts)) { | 60 &max_attempts)) { |
| 61 parameters->max_sync_attempts = max_attempts; | 61 parameters->max_sync_attempts = max_attempts; |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 if (ContainsKey(field_params, kInitialRetryParameterName)) { | 65 if (base::ContainsKey(field_params, kInitialRetryParameterName)) { |
| 66 int initial_retry_delay_sec; | 66 int initial_retry_delay_sec; |
| 67 if (base::StringToInt(field_params[kInitialRetryParameterName], | 67 if (base::StringToInt(field_params[kInitialRetryParameterName], |
| 68 &initial_retry_delay_sec)) { | 68 &initial_retry_delay_sec)) { |
| 69 parameters->initial_retry_delay = | 69 parameters->initial_retry_delay = |
| 70 base::TimeDelta::FromSeconds(initial_retry_delay_sec); | 70 base::TimeDelta::FromSeconds(initial_retry_delay_sec); |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 if (ContainsKey(field_params, kRetryDelayFactorParameterName)) { | 74 if (base::ContainsKey(field_params, kRetryDelayFactorParameterName)) { |
| 75 int retry_delay_factor; | 75 int retry_delay_factor; |
| 76 if (base::StringToInt(field_params[kRetryDelayFactorParameterName], | 76 if (base::StringToInt(field_params[kRetryDelayFactorParameterName], |
| 77 &retry_delay_factor)) { | 77 &retry_delay_factor)) { |
| 78 parameters->retry_delay_factor = retry_delay_factor; | 78 parameters->retry_delay_factor = retry_delay_factor; |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 if (ContainsKey(field_params, kMinSyncRecoveryTimeName)) { | 82 if (base::ContainsKey(field_params, kMinSyncRecoveryTimeName)) { |
| 83 int min_sync_recovery_time_sec; | 83 int min_sync_recovery_time_sec; |
| 84 if (base::StringToInt(field_params[kMinSyncRecoveryTimeName], | 84 if (base::StringToInt(field_params[kMinSyncRecoveryTimeName], |
| 85 &min_sync_recovery_time_sec)) { | 85 &min_sync_recovery_time_sec)) { |
| 86 parameters->min_sync_recovery_time = | 86 parameters->min_sync_recovery_time = |
| 87 base::TimeDelta::FromSeconds(min_sync_recovery_time_sec); | 87 base::TimeDelta::FromSeconds(min_sync_recovery_time_sec); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 if (ContainsKey(field_params, kMaxSyncEventDurationName)) { | 91 if (base::ContainsKey(field_params, kMaxSyncEventDurationName)) { |
| 92 int max_sync_event_duration_sec; | 92 int max_sync_event_duration_sec; |
| 93 if (base::StringToInt(field_params[kMaxSyncEventDurationName], | 93 if (base::StringToInt(field_params[kMaxSyncEventDurationName], |
| 94 &max_sync_event_duration_sec)) { | 94 &max_sync_event_duration_sec)) { |
| 95 parameters->max_sync_event_duration = | 95 parameters->max_sync_event_duration = |
| 96 base::TimeDelta::FromSeconds(max_sync_event_duration_sec); | 96 base::TimeDelta::FromSeconds(max_sync_event_duration_sec); |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 | 99 |
| 100 return; | 100 return; |
| 101 } | 101 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 122 BackgroundSyncLauncherAndroid::LaunchBrowserIfStopped(enabled, min_ms); | 122 BackgroundSyncLauncherAndroid::LaunchBrowserIfStopped(enabled, min_ms); |
| 123 #else | 123 #else |
| 124 // TODO(jkarlin): Use BackgroundModeManager to enter background mode. See | 124 // TODO(jkarlin): Use BackgroundModeManager to enter background mode. See |
| 125 // https://crbug.com/484201. | 125 // https://crbug.com/484201. |
| 126 #endif | 126 #endif |
| 127 } | 127 } |
| 128 | 128 |
| 129 rappor::RapporService* BackgroundSyncControllerImpl::GetRapporService() { | 129 rappor::RapporService* BackgroundSyncControllerImpl::GetRapporService() { |
| 130 return g_browser_process->rappor_service(); | 130 return g_browser_process->rappor_service(); |
| 131 } | 131 } |
| OLD | NEW |