| 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" |
| 11 #include "components/rappor/rappor_utils.h" | 11 #include "components/rappor/public/rappor_utils.h" |
| 12 #include "components/rappor/rappor_service_impl.h" |
| 12 #include "components/variations/variations_associated_data.h" | 13 #include "components/variations/variations_associated_data.h" |
| 13 #include "content/public/browser/background_sync_parameters.h" | 14 #include "content/public/browser/background_sync_parameters.h" |
| 14 | 15 |
| 15 #if defined(OS_ANDROID) | 16 #if defined(OS_ANDROID) |
| 16 #include "chrome/browser/android/background_sync_launcher_android.h" | 17 #include "chrome/browser/android/background_sync_launcher_android.h" |
| 17 #endif | 18 #endif |
| 18 | 19 |
| 19 // static | 20 // static |
| 20 const char BackgroundSyncControllerImpl::kFieldTrialName[] = "BackgroundSync"; | 21 const char BackgroundSyncControllerImpl::kFieldTrialName[] = "BackgroundSync"; |
| 21 const char BackgroundSyncControllerImpl::kDisabledParameterName[] = "disabled"; | 22 const char BackgroundSyncControllerImpl::kDisabledParameterName[] = "disabled"; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 103 |
| 103 void BackgroundSyncControllerImpl::NotifyBackgroundSyncRegistered( | 104 void BackgroundSyncControllerImpl::NotifyBackgroundSyncRegistered( |
| 104 const GURL& origin) { | 105 const GURL& origin) { |
| 105 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 106 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 106 DCHECK_EQ(origin, origin.GetOrigin()); | 107 DCHECK_EQ(origin, origin.GetOrigin()); |
| 107 | 108 |
| 108 if (profile_->IsOffTheRecord()) | 109 if (profile_->IsOffTheRecord()) |
| 109 return; | 110 return; |
| 110 | 111 |
| 111 rappor::SampleDomainAndRegistryFromGURL( | 112 rappor::SampleDomainAndRegistryFromGURL( |
| 112 GetRapporService(), "BackgroundSync.Register.Origin", origin); | 113 GetRapporServiceImpl(), "BackgroundSync.Register.Origin", origin); |
| 113 } | 114 } |
| 114 | 115 |
| 115 void BackgroundSyncControllerImpl::RunInBackground(bool enabled, | 116 void BackgroundSyncControllerImpl::RunInBackground(bool enabled, |
| 116 int64_t min_ms) { | 117 int64_t min_ms) { |
| 117 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 118 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 118 | 119 |
| 119 if (profile_->IsOffTheRecord()) | 120 if (profile_->IsOffTheRecord()) |
| 120 return; | 121 return; |
| 121 #if defined(OS_ANDROID) | 122 #if defined(OS_ANDROID) |
| 122 BackgroundSyncLauncherAndroid::LaunchBrowserIfStopped(enabled, min_ms); | 123 BackgroundSyncLauncherAndroid::LaunchBrowserIfStopped(enabled, min_ms); |
| 123 #else | 124 #else |
| 124 // TODO(jkarlin): Use BackgroundModeManager to enter background mode. See | 125 // TODO(jkarlin): Use BackgroundModeManager to enter background mode. See |
| 125 // https://crbug.com/484201. | 126 // https://crbug.com/484201. |
| 126 #endif | 127 #endif |
| 127 } | 128 } |
| 128 | 129 |
| 129 rappor::RapporService* BackgroundSyncControllerImpl::GetRapporService() { | 130 rappor::RapporServiceImpl* |
| 131 BackgroundSyncControllerImpl::GetRapporServiceImpl() { |
| 130 return g_browser_process->rappor_service(); | 132 return g_browser_process->rappor_service(); |
| 131 } | 133 } |
| OLD | NEW |