| 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 "content/browser/background_sync/background_sync_service_impl.h" | 5 #include "content/browser/background_sync/background_sync_service_impl.h" |
| 6 | 6 |
| 7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
| 8 #include "content/browser/background_sync/background_sync_context_impl.h" | 8 #include "content/browser/background_sync/background_sync_context_impl.h" |
| 9 #include "content/browser/background_sync/background_sync_registration.h" | 9 #include "content/browser/background_sync/background_sync_registration.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 base::Unretained(this) /* the channel is owned by this */)); | 104 base::Unretained(this) /* the channel is owned by this */)); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void BackgroundSyncServiceImpl::OnConnectionError() { | 107 void BackgroundSyncServiceImpl::OnConnectionError() { |
| 108 background_sync_context_->ServiceHadConnectionError(this); | 108 background_sync_context_->ServiceHadConnectionError(this); |
| 109 // |this| is now deleted. | 109 // |this| is now deleted. |
| 110 } | 110 } |
| 111 | 111 |
| 112 void BackgroundSyncServiceImpl::Register(content::SyncRegistrationPtr options, | 112 void BackgroundSyncServiceImpl::Register(content::SyncRegistrationPtr options, |
| 113 int64_t sw_registration_id, | 113 int64_t sw_registration_id, |
| 114 bool requested_from_service_worker, | |
| 115 const RegisterCallback& callback) { | 114 const RegisterCallback& callback) { |
| 116 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 115 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 117 | 116 |
| 118 BackgroundSyncRegistrationOptions mgr_options = | 117 BackgroundSyncRegistrationOptions mgr_options = |
| 119 ToBackgroundSyncRegistrationOptions(options); | 118 ToBackgroundSyncRegistrationOptions(options); |
| 120 | 119 |
| 121 BackgroundSyncManager* background_sync_manager = | 120 BackgroundSyncManager* background_sync_manager = |
| 122 background_sync_context_->background_sync_manager(); | 121 background_sync_context_->background_sync_manager(); |
| 123 DCHECK(background_sync_manager); | 122 DCHECK(background_sync_manager); |
| 124 background_sync_manager->Register( | 123 background_sync_manager->Register( |
| 125 sw_registration_id, mgr_options, requested_from_service_worker, | 124 sw_registration_id, mgr_options, |
| 126 base::Bind(&BackgroundSyncServiceImpl::OnRegisterResult, | 125 base::Bind(&BackgroundSyncServiceImpl::OnRegisterResult, |
| 127 weak_ptr_factory_.GetWeakPtr(), callback)); | 126 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 128 } | 127 } |
| 129 | 128 |
| 130 void BackgroundSyncServiceImpl::Unregister( | 129 void BackgroundSyncServiceImpl::Unregister( |
| 131 BackgroundSyncPeriodicity periodicity, | 130 BackgroundSyncPeriodicity periodicity, |
| 132 int64_t id, | 131 int64_t id, |
| 133 const mojo::String& tag, | 132 const mojo::String& tag, |
| 134 int64_t sw_registration_id, | 133 int64_t sw_registration_id, |
| 135 const UnregisterCallback& callback) { | 134 const UnregisterCallback& callback) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 const std::vector<BackgroundSyncRegistration>& result_registrations) { | 206 const std::vector<BackgroundSyncRegistration>& result_registrations) { |
| 208 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 207 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 209 mojo::Array<content::SyncRegistrationPtr> mojo_registrations(0); | 208 mojo::Array<content::SyncRegistrationPtr> mojo_registrations(0); |
| 210 for (const auto& registration : result_registrations) | 209 for (const auto& registration : result_registrations) |
| 211 mojo_registrations.push_back(ToMojoRegistration(registration)); | 210 mojo_registrations.push_back(ToMojoRegistration(registration)); |
| 212 callback.Run(static_cast<content::BackgroundSyncError>(status), | 211 callback.Run(static_cast<content::BackgroundSyncError>(status), |
| 213 mojo_registrations.Pass()); | 212 mojo_registrations.Pass()); |
| 214 } | 213 } |
| 215 | 214 |
| 216 } // namespace content | 215 } // namespace content |
| OLD | NEW |