| 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_manager.h" | 5 #include "content/browser/background_sync/background_sync_manager.h" |
| 6 | 6 |
| 7 #include "base/barrier_closure.h" | 7 #include "base/barrier_closure.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/location.h" | |
| 10 #include "base/single_thread_task_runner.h" | |
| 11 #include "base/thread_task_runner_handle.h" | |
| 12 #include "content/browser/background_sync/background_sync_network_observer.h" | 9 #include "content/browser/background_sync/background_sync_network_observer.h" |
| 13 #include "content/browser/background_sync/background_sync_power_observer.h" | 10 #include "content/browser/background_sync/background_sync_power_observer.h" |
| 14 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 11 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 15 #include "content/browser/service_worker/service_worker_storage.h" | 12 #include "content/browser/service_worker/service_worker_storage.h" |
| 16 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 17 | 14 |
| 18 #if defined(OS_ANDROID) | 15 #if defined(OS_ANDROID) |
| 19 #include "content/browser/android/background_sync_launcher_android.h" | 16 #include "content/browser/android/background_sync_launcher_android.h" |
| 20 #endif | 17 #endif |
| 21 | 18 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 68 |
| 72 void BackgroundSyncManager::Register( | 69 void BackgroundSyncManager::Register( |
| 73 int64 sw_registration_id, | 70 int64 sw_registration_id, |
| 74 const BackgroundSyncRegistration& sync_registration, | 71 const BackgroundSyncRegistration& sync_registration, |
| 75 const StatusAndRegistrationCallback& callback) { | 72 const StatusAndRegistrationCallback& callback) { |
| 76 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 73 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 77 DCHECK_EQ(BackgroundSyncRegistration::kInvalidRegistrationId, | 74 DCHECK_EQ(BackgroundSyncRegistration::kInvalidRegistrationId, |
| 78 sync_registration.id); | 75 sync_registration.id); |
| 79 | 76 |
| 80 if (disabled_) { | 77 if (disabled_) { |
| 81 base::ThreadTaskRunnerHandle::Get()->PostTask( | 78 base::MessageLoop::current()->PostTask( |
| 82 FROM_HERE, | 79 FROM_HERE, |
| 83 base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); | 80 base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); |
| 84 return; | 81 return; |
| 85 } | 82 } |
| 86 | 83 |
| 87 op_scheduler_.ScheduleOperation(base::Bind( | 84 op_scheduler_.ScheduleOperation(base::Bind( |
| 88 &BackgroundSyncManager::RegisterImpl, weak_ptr_factory_.GetWeakPtr(), | 85 &BackgroundSyncManager::RegisterImpl, weak_ptr_factory_.GetWeakPtr(), |
| 89 sw_registration_id, sync_registration, | 86 sw_registration_id, sync_registration, |
| 90 MakeStatusAndRegistrationCompletion(callback))); | 87 MakeStatusAndRegistrationCompletion(callback))); |
| 91 } | 88 } |
| 92 | 89 |
| 93 void BackgroundSyncManager::Unregister( | 90 void BackgroundSyncManager::Unregister( |
| 94 int64 sw_registration_id, | 91 int64 sw_registration_id, |
| 95 const std::string& sync_registration_tag, | 92 const std::string& sync_registration_tag, |
| 96 SyncPeriodicity periodicity, | 93 SyncPeriodicity periodicity, |
| 97 BackgroundSyncRegistration::RegistrationId sync_registration_id, | 94 BackgroundSyncRegistration::RegistrationId sync_registration_id, |
| 98 const StatusCallback& callback) { | 95 const StatusCallback& callback) { |
| 99 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 96 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 100 | 97 |
| 101 if (disabled_) { | 98 if (disabled_) { |
| 102 base::ThreadTaskRunnerHandle::Get()->PostTask( | 99 base::MessageLoop::current()->PostTask( |
| 103 FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE)); | 100 FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE)); |
| 104 return; | 101 return; |
| 105 } | 102 } |
| 106 | 103 |
| 107 RegistrationKey registration_key(sync_registration_tag, periodicity); | 104 RegistrationKey registration_key(sync_registration_tag, periodicity); |
| 108 | 105 |
| 109 op_scheduler_.ScheduleOperation(base::Bind( | 106 op_scheduler_.ScheduleOperation(base::Bind( |
| 110 &BackgroundSyncManager::UnregisterImpl, weak_ptr_factory_.GetWeakPtr(), | 107 &BackgroundSyncManager::UnregisterImpl, weak_ptr_factory_.GetWeakPtr(), |
| 111 sw_registration_id, registration_key, sync_registration_id, | 108 sw_registration_id, registration_key, sync_registration_id, |
| 112 MakeStatusCompletion(callback))); | 109 MakeStatusCompletion(callback))); |
| 113 } | 110 } |
| 114 | 111 |
| 115 void BackgroundSyncManager::GetRegistration( | 112 void BackgroundSyncManager::GetRegistration( |
| 116 int64 sw_registration_id, | 113 int64 sw_registration_id, |
| 117 const std::string& sync_registration_tag, | 114 const std::string& sync_registration_tag, |
| 118 SyncPeriodicity periodicity, | 115 SyncPeriodicity periodicity, |
| 119 const StatusAndRegistrationCallback& callback) { | 116 const StatusAndRegistrationCallback& callback) { |
| 120 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 117 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 121 | 118 |
| 122 if (disabled_) { | 119 if (disabled_) { |
| 123 base::ThreadTaskRunnerHandle::Get()->PostTask( | 120 base::MessageLoop::current()->PostTask( |
| 124 FROM_HERE, | 121 FROM_HERE, |
| 125 base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); | 122 base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); |
| 126 return; | 123 return; |
| 127 } | 124 } |
| 128 | 125 |
| 129 RegistrationKey registration_key(sync_registration_tag, periodicity); | 126 RegistrationKey registration_key(sync_registration_tag, periodicity); |
| 130 | 127 |
| 131 op_scheduler_.ScheduleOperation(base::Bind( | 128 op_scheduler_.ScheduleOperation(base::Bind( |
| 132 &BackgroundSyncManager::GetRegistrationImpl, | 129 &BackgroundSyncManager::GetRegistrationImpl, |
| 133 weak_ptr_factory_.GetWeakPtr(), sw_registration_id, registration_key, | 130 weak_ptr_factory_.GetWeakPtr(), sw_registration_id, registration_key, |
| 134 MakeStatusAndRegistrationCompletion(callback))); | 131 MakeStatusAndRegistrationCompletion(callback))); |
| 135 } | 132 } |
| 136 | 133 |
| 137 void BackgroundSyncManager::GetRegistrations( | 134 void BackgroundSyncManager::GetRegistrations( |
| 138 int64 sw_registration_id, | 135 int64 sw_registration_id, |
| 139 SyncPeriodicity periodicity, | 136 SyncPeriodicity periodicity, |
| 140 const StatusAndRegistrationsCallback& callback) { | 137 const StatusAndRegistrationsCallback& callback) { |
| 141 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 138 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 142 | 139 |
| 143 if (disabled_) { | 140 if (disabled_) { |
| 144 base::ThreadTaskRunnerHandle::Get()->PostTask( | 141 base::MessageLoop::current()->PostTask( |
| 145 FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE, | 142 FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE, |
| 146 std::vector<BackgroundSyncRegistration>())); | 143 std::vector<BackgroundSyncRegistration>())); |
| 147 return; | 144 return; |
| 148 } | 145 } |
| 149 | 146 |
| 150 op_scheduler_.ScheduleOperation( | 147 op_scheduler_.ScheduleOperation( |
| 151 base::Bind(&BackgroundSyncManager::GetRegistrationsImpl, | 148 base::Bind(&BackgroundSyncManager::GetRegistrationsImpl, |
| 152 weak_ptr_factory_.GetWeakPtr(), sw_registration_id, | 149 weak_ptr_factory_.GetWeakPtr(), sw_registration_id, |
| 153 periodicity, MakeStatusAndRegistrationsCompletion(callback))); | 150 periodicity, MakeStatusAndRegistrationsCompletion(callback))); |
| 154 } | 151 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 196 |
| 200 op_scheduler_.ScheduleOperation(base::Bind(&BackgroundSyncManager::InitImpl, | 197 op_scheduler_.ScheduleOperation(base::Bind(&BackgroundSyncManager::InitImpl, |
| 201 weak_ptr_factory_.GetWeakPtr(), | 198 weak_ptr_factory_.GetWeakPtr(), |
| 202 MakeEmptyCompletion())); | 199 MakeEmptyCompletion())); |
| 203 } | 200 } |
| 204 | 201 |
| 205 void BackgroundSyncManager::InitImpl(const base::Closure& callback) { | 202 void BackgroundSyncManager::InitImpl(const base::Closure& callback) { |
| 206 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 203 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 207 | 204 |
| 208 if (disabled_) { | 205 if (disabled_) { |
| 209 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 206 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); |
| 210 base::Bind(callback)); | |
| 211 return; | 207 return; |
| 212 } | 208 } |
| 213 | 209 |
| 214 GetDataFromBackend( | 210 GetDataFromBackend( |
| 215 kBackgroundSyncUserDataKey, | 211 kBackgroundSyncUserDataKey, |
| 216 base::Bind(&BackgroundSyncManager::InitDidGetDataFromBackend, | 212 base::Bind(&BackgroundSyncManager::InitDidGetDataFromBackend, |
| 217 weak_ptr_factory_.GetWeakPtr(), callback)); | 213 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 218 } | 214 } |
| 219 | 215 |
| 220 void BackgroundSyncManager::InitDidGetDataFromBackend( | 216 void BackgroundSyncManager::InitDidGetDataFromBackend( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 } | 269 } |
| 274 | 270 |
| 275 if (corruption_detected) { | 271 if (corruption_detected) { |
| 276 LOG(ERROR) << "Corruption detected in background sync backend"; | 272 LOG(ERROR) << "Corruption detected in background sync backend"; |
| 277 DisableAndClearManager(base::Bind(callback)); | 273 DisableAndClearManager(base::Bind(callback)); |
| 278 return; | 274 return; |
| 279 } | 275 } |
| 280 | 276 |
| 281 FireReadyEvents(); | 277 FireReadyEvents(); |
| 282 | 278 |
| 283 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 279 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); |
| 284 base::Bind(callback)); | |
| 285 } | 280 } |
| 286 | 281 |
| 287 void BackgroundSyncManager::RegisterImpl( | 282 void BackgroundSyncManager::RegisterImpl( |
| 288 int64 sw_registration_id, | 283 int64 sw_registration_id, |
| 289 const BackgroundSyncRegistration& sync_registration, | 284 const BackgroundSyncRegistration& sync_registration, |
| 290 const StatusAndRegistrationCallback& callback) { | 285 const StatusAndRegistrationCallback& callback) { |
| 291 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 286 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 292 | 287 |
| 293 if (disabled_) { | 288 if (disabled_) { |
| 294 base::ThreadTaskRunnerHandle::Get()->PostTask( | 289 base::MessageLoop::current()->PostTask( |
| 295 FROM_HERE, | 290 FROM_HERE, |
| 296 base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); | 291 base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); |
| 297 return; | 292 return; |
| 298 } | 293 } |
| 299 | 294 |
| 300 const BackgroundSyncRegistration* existing_registration = LookupRegistration( | 295 const BackgroundSyncRegistration* existing_registration = LookupRegistration( |
| 301 sw_registration_id, RegistrationKey(sync_registration)); | 296 sw_registration_id, RegistrationKey(sync_registration)); |
| 302 if (existing_registration && | 297 if (existing_registration && |
| 303 existing_registration->Equals(sync_registration)) { | 298 existing_registration->Equals(sync_registration)) { |
| 304 base::ThreadTaskRunnerHandle::Get()->PostTask( | 299 base::MessageLoop::current()->PostTask( |
| 305 FROM_HERE, base::Bind(callback, ERROR_TYPE_OK, *existing_registration)); | 300 FROM_HERE, base::Bind(callback, ERROR_TYPE_OK, *existing_registration)); |
| 306 return; | 301 return; |
| 307 } | 302 } |
| 308 | 303 |
| 309 BackgroundSyncRegistration new_registration = sync_registration; | 304 BackgroundSyncRegistration new_registration = sync_registration; |
| 310 BackgroundSyncRegistrations* registrations = | 305 BackgroundSyncRegistrations* registrations = |
| 311 &sw_to_registrations_map_[sw_registration_id]; | 306 &sw_to_registrations_map_[sw_registration_id]; |
| 312 new_registration.id = registrations->next_id++; | 307 new_registration.id = registrations->next_id++; |
| 313 | 308 |
| 314 ServiceWorkerRegistration* sw_registration = | 309 ServiceWorkerRegistration* sw_registration = |
| 315 service_worker_context_->GetLiveRegistration(sw_registration_id); | 310 service_worker_context_->GetLiveRegistration(sw_registration_id); |
| 316 if (!sw_registration || !sw_registration->active_version()) { | 311 if (!sw_registration || !sw_registration->active_version()) { |
| 317 base::ThreadTaskRunnerHandle::Get()->PostTask( | 312 base::MessageLoop::current()->PostTask( |
| 318 FROM_HERE, base::Bind(callback, ERROR_TYPE_NO_SERVICE_WORKER, | 313 FROM_HERE, base::Bind(callback, ERROR_TYPE_NO_SERVICE_WORKER, |
| 319 BackgroundSyncRegistration())); | 314 BackgroundSyncRegistration())); |
| 320 return; | 315 return; |
| 321 } | 316 } |
| 322 | 317 |
| 323 AddRegistrationToMap(sw_registration_id, | 318 AddRegistrationToMap(sw_registration_id, |
| 324 sw_registration->pattern().GetOrigin(), | 319 sw_registration->pattern().GetOrigin(), |
| 325 new_registration); | 320 new_registration); |
| 326 | 321 |
| 327 StoreRegistrations( | 322 StoreRegistrations( |
| 328 sw_registration_id, | 323 sw_registration_id, |
| 329 base::Bind(&BackgroundSyncManager::RegisterDidStore, | 324 base::Bind(&BackgroundSyncManager::RegisterDidStore, |
| 330 weak_ptr_factory_.GetWeakPtr(), sw_registration_id, | 325 weak_ptr_factory_.GetWeakPtr(), sw_registration_id, |
| 331 new_registration, callback)); | 326 new_registration, callback)); |
| 332 } | 327 } |
| 333 | 328 |
| 334 void BackgroundSyncManager::DisableAndClearManager( | 329 void BackgroundSyncManager::DisableAndClearManager( |
| 335 const base::Closure& callback) { | 330 const base::Closure& callback) { |
| 336 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 331 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 337 | 332 |
| 338 if (disabled_) { | 333 if (disabled_) { |
| 339 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 334 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); |
| 340 base::Bind(callback)); | |
| 341 return; | 335 return; |
| 342 } | 336 } |
| 343 | 337 |
| 344 disabled_ = true; | 338 disabled_ = true; |
| 345 sw_to_registrations_map_.clear(); | 339 sw_to_registrations_map_.clear(); |
| 346 | 340 |
| 347 // Delete all backend entries. The memory representation of registered syncs | 341 // Delete all backend entries. The memory representation of registered syncs |
| 348 // may be out of sync with storage (e.g., due to corruption detection on | 342 // may be out of sync with storage (e.g., due to corruption detection on |
| 349 // loading from storage), so reload the registrations from storage again. | 343 // loading from storage), so reload the registrations from storage again. |
| 350 GetDataFromBackend( | 344 GetDataFromBackend( |
| 351 kBackgroundSyncUserDataKey, | 345 kBackgroundSyncUserDataKey, |
| 352 base::Bind(&BackgroundSyncManager::DisableAndClearDidGetRegistrations, | 346 base::Bind(&BackgroundSyncManager::DisableAndClearDidGetRegistrations, |
| 353 weak_ptr_factory_.GetWeakPtr(), callback)); | 347 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 354 } | 348 } |
| 355 | 349 |
| 356 void BackgroundSyncManager::DisableAndClearDidGetRegistrations( | 350 void BackgroundSyncManager::DisableAndClearDidGetRegistrations( |
| 357 const base::Closure& callback, | 351 const base::Closure& callback, |
| 358 const std::vector<std::pair<int64, std::string>>& user_data, | 352 const std::vector<std::pair<int64, std::string>>& user_data, |
| 359 ServiceWorkerStatusCode status) { | 353 ServiceWorkerStatusCode status) { |
| 360 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 354 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 361 | 355 |
| 362 if (status != SERVICE_WORKER_OK || user_data.empty()) { | 356 if (status != SERVICE_WORKER_OK || user_data.empty()) { |
| 363 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 357 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); |
| 364 base::Bind(callback)); | |
| 365 return; | 358 return; |
| 366 } | 359 } |
| 367 | 360 |
| 368 base::Closure barrier_closure = | 361 base::Closure barrier_closure = |
| 369 base::BarrierClosure(user_data.size(), base::Bind(callback)); | 362 base::BarrierClosure(user_data.size(), base::Bind(callback)); |
| 370 | 363 |
| 371 for (const auto& sw_id_and_regs : user_data) { | 364 for (const auto& sw_id_and_regs : user_data) { |
| 372 service_worker_context_->ClearRegistrationUserData( | 365 service_worker_context_->ClearRegistrationUserData( |
| 373 sw_id_and_regs.first, kBackgroundSyncUserDataKey, | 366 sw_id_and_regs.first, kBackgroundSyncUserDataKey, |
| 374 base::Bind(&BackgroundSyncManager::DisableAndClearManagerClearedOne, | 367 base::Bind(&BackgroundSyncManager::DisableAndClearManagerClearedOne, |
| 375 weak_ptr_factory_.GetWeakPtr(), barrier_closure)); | 368 weak_ptr_factory_.GetWeakPtr(), barrier_closure)); |
| 376 } | 369 } |
| 377 } | 370 } |
| 378 | 371 |
| 379 void BackgroundSyncManager::DisableAndClearManagerClearedOne( | 372 void BackgroundSyncManager::DisableAndClearManagerClearedOne( |
| 380 const base::Closure& barrier_closure, | 373 const base::Closure& barrier_closure, |
| 381 ServiceWorkerStatusCode status) { | 374 ServiceWorkerStatusCode status) { |
| 382 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 375 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 383 | 376 |
| 384 // The status doesn't matter at this point, there is nothing else to be done. | 377 // The status doesn't matter at this point, there is nothing else to be done. |
| 385 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 378 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 386 base::Bind(barrier_closure)); | 379 base::Bind(barrier_closure)); |
| 387 } | 380 } |
| 388 | 381 |
| 389 BackgroundSyncManager::BackgroundSyncRegistration* | 382 BackgroundSyncManager::BackgroundSyncRegistration* |
| 390 BackgroundSyncManager::LookupRegistration( | 383 BackgroundSyncManager::LookupRegistration( |
| 391 int64 sw_registration_id, | 384 int64 sw_registration_id, |
| 392 const RegistrationKey& registration_key) { | 385 const RegistrationKey& registration_key) { |
| 393 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 386 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 394 | 387 |
| 395 SWIdToRegistrationsMap::iterator it = | 388 SWIdToRegistrationsMap::iterator it = |
| 396 sw_to_registrations_map_.find(sw_registration_id); | 389 sw_to_registrations_map_.find(sw_registration_id); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 void BackgroundSyncManager::RegisterDidStore( | 438 void BackgroundSyncManager::RegisterDidStore( |
| 446 int64 sw_registration_id, | 439 int64 sw_registration_id, |
| 447 const BackgroundSyncRegistration& new_registration, | 440 const BackgroundSyncRegistration& new_registration, |
| 448 const StatusAndRegistrationCallback& callback, | 441 const StatusAndRegistrationCallback& callback, |
| 449 ServiceWorkerStatusCode status) { | 442 ServiceWorkerStatusCode status) { |
| 450 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 443 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 451 | 444 |
| 452 if (status == SERVICE_WORKER_ERROR_NOT_FOUND) { | 445 if (status == SERVICE_WORKER_ERROR_NOT_FOUND) { |
| 453 // The registration is gone. | 446 // The registration is gone. |
| 454 sw_to_registrations_map_.erase(sw_registration_id); | 447 sw_to_registrations_map_.erase(sw_registration_id); |
| 455 base::ThreadTaskRunnerHandle::Get()->PostTask( | 448 base::MessageLoop::current()->PostTask( |
| 456 FROM_HERE, | 449 FROM_HERE, |
| 457 base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); | 450 base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); |
| 458 return; | 451 return; |
| 459 } | 452 } |
| 460 | 453 |
| 461 if (status != SERVICE_WORKER_OK) { | 454 if (status != SERVICE_WORKER_OK) { |
| 462 LOG(ERROR) << "BackgroundSync failed to store registration due to backend " | 455 LOG(ERROR) << "BackgroundSync failed to store registration due to backend " |
| 463 "failure."; | 456 "failure."; |
| 464 DisableAndClearManager( | 457 DisableAndClearManager( |
| 465 base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); | 458 base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); |
| 466 return; | 459 return; |
| 467 } | 460 } |
| 468 | 461 |
| 469 FireReadyEvents(); | 462 FireReadyEvents(); |
| 470 base::ThreadTaskRunnerHandle::Get()->PostTask( | 463 base::MessageLoop::current()->PostTask( |
| 471 FROM_HERE, base::Bind(callback, ERROR_TYPE_OK, new_registration)); | 464 FROM_HERE, base::Bind(callback, ERROR_TYPE_OK, new_registration)); |
| 472 } | 465 } |
| 473 | 466 |
| 474 void BackgroundSyncManager::RemoveRegistrationFromMap( | 467 void BackgroundSyncManager::RemoveRegistrationFromMap( |
| 475 int64 sw_registration_id, | 468 int64 sw_registration_id, |
| 476 const RegistrationKey& registration_key) { | 469 const RegistrationKey& registration_key) { |
| 477 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 470 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 478 DCHECK(LookupRegistration(sw_registration_id, registration_key)); | 471 DCHECK(LookupRegistration(sw_registration_id, registration_key)); |
| 479 | 472 |
| 480 BackgroundSyncRegistrations* registrations = | 473 BackgroundSyncRegistrations* registrations = |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 } | 523 } |
| 531 | 524 |
| 532 void BackgroundSyncManager::UnregisterImpl( | 525 void BackgroundSyncManager::UnregisterImpl( |
| 533 int64 sw_registration_id, | 526 int64 sw_registration_id, |
| 534 const RegistrationKey& registration_key, | 527 const RegistrationKey& registration_key, |
| 535 BackgroundSyncRegistration::RegistrationId sync_registration_id, | 528 BackgroundSyncRegistration::RegistrationId sync_registration_id, |
| 536 const StatusCallback& callback) { | 529 const StatusCallback& callback) { |
| 537 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 530 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 538 | 531 |
| 539 if (disabled_) { | 532 if (disabled_) { |
| 540 base::ThreadTaskRunnerHandle::Get()->PostTask( | 533 base::MessageLoop::current()->PostTask( |
| 541 FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE)); | 534 FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE)); |
| 542 return; | 535 return; |
| 543 } | 536 } |
| 544 | 537 |
| 545 const BackgroundSyncRegistration* existing_registration = | 538 const BackgroundSyncRegistration* existing_registration = |
| 546 LookupRegistration(sw_registration_id, registration_key); | 539 LookupRegistration(sw_registration_id, registration_key); |
| 547 if (!existing_registration || | 540 if (!existing_registration || |
| 548 existing_registration->id != sync_registration_id) { | 541 existing_registration->id != sync_registration_id) { |
| 549 base::ThreadTaskRunnerHandle::Get()->PostTask( | 542 base::MessageLoop::current()->PostTask( |
| 550 FROM_HERE, base::Bind(callback, ERROR_TYPE_NOT_FOUND)); | 543 FROM_HERE, base::Bind(callback, ERROR_TYPE_NOT_FOUND)); |
| 551 return; | 544 return; |
| 552 } | 545 } |
| 553 | 546 |
| 554 RemoveRegistrationFromMap(sw_registration_id, registration_key); | 547 RemoveRegistrationFromMap(sw_registration_id, registration_key); |
| 555 | 548 |
| 556 StoreRegistrations( | 549 StoreRegistrations( |
| 557 sw_registration_id, | 550 sw_registration_id, |
| 558 base::Bind(&BackgroundSyncManager::UnregisterDidStore, | 551 base::Bind(&BackgroundSyncManager::UnregisterDidStore, |
| 559 weak_ptr_factory_.GetWeakPtr(), sw_registration_id, callback)); | 552 weak_ptr_factory_.GetWeakPtr(), sw_registration_id, callback)); |
| 560 } | 553 } |
| 561 | 554 |
| 562 void BackgroundSyncManager::UnregisterDidStore( | 555 void BackgroundSyncManager::UnregisterDidStore( |
| 563 int64 sw_registration_id, | 556 int64 sw_registration_id, |
| 564 const StatusCallback& callback, | 557 const StatusCallback& callback, |
| 565 ServiceWorkerStatusCode status) { | 558 ServiceWorkerStatusCode status) { |
| 566 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 559 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 567 | 560 |
| 568 if (status == SERVICE_WORKER_ERROR_NOT_FOUND) { | 561 if (status == SERVICE_WORKER_ERROR_NOT_FOUND) { |
| 569 // ServiceWorker was unregistered. | 562 // ServiceWorker was unregistered. |
| 570 sw_to_registrations_map_.erase(sw_registration_id); | 563 sw_to_registrations_map_.erase(sw_registration_id); |
| 571 base::ThreadTaskRunnerHandle::Get()->PostTask( | 564 base::MessageLoop::current()->PostTask( |
| 572 FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE)); | 565 FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE)); |
| 573 return; | 566 return; |
| 574 } | 567 } |
| 575 | 568 |
| 576 if (status != SERVICE_WORKER_OK) { | 569 if (status != SERVICE_WORKER_OK) { |
| 577 LOG(ERROR) << "BackgroundSync failed to unregister due to backend failure."; | 570 LOG(ERROR) << "BackgroundSync failed to unregister due to backend failure."; |
| 578 DisableAndClearManager(base::Bind(callback, ERROR_TYPE_STORAGE)); | 571 DisableAndClearManager(base::Bind(callback, ERROR_TYPE_STORAGE)); |
| 579 return; | 572 return; |
| 580 } | 573 } |
| 581 | 574 |
| 582 base::ThreadTaskRunnerHandle::Get()->PostTask( | 575 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 583 FROM_HERE, base::Bind(callback, ERROR_TYPE_OK)); | 576 base::Bind(callback, ERROR_TYPE_OK)); |
| 584 } | 577 } |
| 585 | 578 |
| 586 void BackgroundSyncManager::GetRegistrationImpl( | 579 void BackgroundSyncManager::GetRegistrationImpl( |
| 587 int64 sw_registration_id, | 580 int64 sw_registration_id, |
| 588 const RegistrationKey& registration_key, | 581 const RegistrationKey& registration_key, |
| 589 const StatusAndRegistrationCallback& callback) { | 582 const StatusAndRegistrationCallback& callback) { |
| 590 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 583 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 591 | 584 |
| 592 if (disabled_) { | 585 if (disabled_) { |
| 593 base::ThreadTaskRunnerHandle::Get()->PostTask( | 586 base::MessageLoop::current()->PostTask( |
| 594 FROM_HERE, | 587 FROM_HERE, |
| 595 base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); | 588 base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); |
| 596 return; | 589 return; |
| 597 } | 590 } |
| 598 | 591 |
| 599 const BackgroundSyncRegistration* out_registration = | 592 const BackgroundSyncRegistration* out_registration = |
| 600 LookupRegistration(sw_registration_id, registration_key); | 593 LookupRegistration(sw_registration_id, registration_key); |
| 601 if (!out_registration) { | 594 if (!out_registration) { |
| 602 base::ThreadTaskRunnerHandle::Get()->PostTask( | 595 base::MessageLoop::current()->PostTask( |
| 603 FROM_HERE, base::Bind(callback, ERROR_TYPE_NOT_FOUND, | 596 FROM_HERE, base::Bind(callback, ERROR_TYPE_NOT_FOUND, |
| 604 BackgroundSyncRegistration())); | 597 BackgroundSyncRegistration())); |
| 605 return; | 598 return; |
| 606 } | 599 } |
| 607 | 600 |
| 608 base::ThreadTaskRunnerHandle::Get()->PostTask( | 601 base::MessageLoop::current()->PostTask( |
| 609 FROM_HERE, base::Bind(callback, ERROR_TYPE_OK, *out_registration)); | 602 FROM_HERE, base::Bind(callback, ERROR_TYPE_OK, *out_registration)); |
| 610 } | 603 } |
| 611 | 604 |
| 612 void BackgroundSyncManager::GetRegistrationsImpl( | 605 void BackgroundSyncManager::GetRegistrationsImpl( |
| 613 int64 sw_registration_id, | 606 int64 sw_registration_id, |
| 614 SyncPeriodicity periodicity, | 607 SyncPeriodicity periodicity, |
| 615 const StatusAndRegistrationsCallback& callback) { | 608 const StatusAndRegistrationsCallback& callback) { |
| 616 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 609 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 617 | 610 |
| 618 std::vector<BackgroundSyncRegistration> out_registrations; | 611 std::vector<BackgroundSyncRegistration> out_registrations; |
| 619 | 612 |
| 620 if (disabled_) { | 613 if (disabled_) { |
| 621 base::ThreadTaskRunnerHandle::Get()->PostTask( | 614 base::MessageLoop::current()->PostTask( |
| 622 FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE, out_registrations)); | 615 FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE, out_registrations)); |
| 623 return; | 616 return; |
| 624 } | 617 } |
| 625 | 618 |
| 626 SWIdToRegistrationsMap::iterator it = | 619 SWIdToRegistrationsMap::iterator it = |
| 627 sw_to_registrations_map_.find(sw_registration_id); | 620 sw_to_registrations_map_.find(sw_registration_id); |
| 628 | 621 |
| 629 if (it != sw_to_registrations_map_.end()) { | 622 if (it != sw_to_registrations_map_.end()) { |
| 630 const BackgroundSyncRegistrations& registrations = it->second; | 623 const BackgroundSyncRegistrations& registrations = it->second; |
| 631 for (const auto& tag_and_registration : registrations.registration_map) { | 624 for (const auto& tag_and_registration : registrations.registration_map) { |
| 632 const BackgroundSyncRegistration& registration = | 625 const BackgroundSyncRegistration& registration = |
| 633 tag_and_registration.second; | 626 tag_and_registration.second; |
| 634 if (registration.periodicity == periodicity) | 627 if (registration.periodicity == periodicity) |
| 635 out_registrations.push_back(registration); | 628 out_registrations.push_back(registration); |
| 636 } | 629 } |
| 637 } | 630 } |
| 638 | 631 |
| 639 base::ThreadTaskRunnerHandle::Get()->PostTask( | 632 base::MessageLoop::current()->PostTask( |
| 640 FROM_HERE, base::Bind(callback, ERROR_TYPE_OK, out_registrations)); | 633 FROM_HERE, base::Bind(callback, ERROR_TYPE_OK, out_registrations)); |
| 641 } | 634 } |
| 642 | 635 |
| 643 bool BackgroundSyncManager::IsRegistrationReadyToFire( | 636 bool BackgroundSyncManager::IsRegistrationReadyToFire( |
| 644 const BackgroundSyncRegistration& registration) { | 637 const BackgroundSyncRegistration& registration) { |
| 645 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 638 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 646 | 639 |
| 647 // TODO(jkarlin): Add support for firing periodic registrations. | 640 // TODO(jkarlin): Add support for firing periodic registrations. |
| 648 if (registration.periodicity == SYNC_PERIODIC) | 641 if (registration.periodicity == SYNC_PERIODIC) |
| 649 return false; | 642 return false; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 | 689 |
| 697 op_scheduler_.ScheduleOperation( | 690 op_scheduler_.ScheduleOperation( |
| 698 base::Bind(&BackgroundSyncManager::FireReadyEventsImpl, | 691 base::Bind(&BackgroundSyncManager::FireReadyEventsImpl, |
| 699 weak_ptr_factory_.GetWeakPtr(), MakeEmptyCompletion())); | 692 weak_ptr_factory_.GetWeakPtr(), MakeEmptyCompletion())); |
| 700 } | 693 } |
| 701 | 694 |
| 702 void BackgroundSyncManager::FireReadyEventsImpl(const base::Closure& callback) { | 695 void BackgroundSyncManager::FireReadyEventsImpl(const base::Closure& callback) { |
| 703 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 696 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 704 | 697 |
| 705 if (disabled_) { | 698 if (disabled_) { |
| 706 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 699 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); |
| 707 base::Bind(callback)); | |
| 708 return; | 700 return; |
| 709 } | 701 } |
| 710 | 702 |
| 711 // Find the registrations that are ready to run. | 703 // Find the registrations that are ready to run. |
| 712 std::vector<std::pair<int64, RegistrationKey>> sw_id_and_keys_to_fire; | 704 std::vector<std::pair<int64, RegistrationKey>> sw_id_and_keys_to_fire; |
| 713 | 705 |
| 714 for (auto& sw_id_and_registrations : sw_to_registrations_map_) { | 706 for (auto& sw_id_and_registrations : sw_to_registrations_map_) { |
| 715 const int64 service_worker_id = sw_id_and_registrations.first; | 707 const int64 service_worker_id = sw_id_and_registrations.first; |
| 716 for (auto& key_and_registration : | 708 for (auto& key_and_registration : |
| 717 sw_id_and_registrations.second.registration_map) { | 709 sw_id_and_registrations.second.registration_map) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 void BackgroundSyncManager::FireReadyEventsDidFindRegistration( | 742 void BackgroundSyncManager::FireReadyEventsDidFindRegistration( |
| 751 const RegistrationKey& registration_key, | 743 const RegistrationKey& registration_key, |
| 752 BackgroundSyncRegistration::RegistrationId registration_id, | 744 BackgroundSyncRegistration::RegistrationId registration_id, |
| 753 const base::Closure& callback, | 745 const base::Closure& callback, |
| 754 ServiceWorkerStatusCode service_worker_status, | 746 ServiceWorkerStatusCode service_worker_status, |
| 755 const scoped_refptr<ServiceWorkerRegistration>& | 747 const scoped_refptr<ServiceWorkerRegistration>& |
| 756 service_worker_registration) { | 748 service_worker_registration) { |
| 757 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 749 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 758 | 750 |
| 759 if (service_worker_status != SERVICE_WORKER_OK) { | 751 if (service_worker_status != SERVICE_WORKER_OK) { |
| 760 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 752 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); |
| 761 base::Bind(callback)); | |
| 762 return; | 753 return; |
| 763 } | 754 } |
| 764 | 755 |
| 765 FireOneShotSync( | 756 FireOneShotSync( |
| 766 service_worker_registration->active_version(), | 757 service_worker_registration->active_version(), |
| 767 base::Bind(&BackgroundSyncManager::EventComplete, | 758 base::Bind(&BackgroundSyncManager::EventComplete, |
| 768 weak_ptr_factory_.GetWeakPtr(), service_worker_registration, | 759 weak_ptr_factory_.GetWeakPtr(), service_worker_registration, |
| 769 service_worker_registration->id(), registration_key, | 760 service_worker_registration->id(), registration_key, |
| 770 registration_id)); | 761 registration_id)); |
| 771 | 762 |
| 772 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 763 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); |
| 773 base::Bind(callback)); | |
| 774 } | 764 } |
| 775 | 765 |
| 776 // |service_worker_registration| is just to keep the registration alive | 766 // |service_worker_registration| is just to keep the registration alive |
| 777 // while the event is firing. | 767 // while the event is firing. |
| 778 void BackgroundSyncManager::EventComplete( | 768 void BackgroundSyncManager::EventComplete( |
| 779 const scoped_refptr<ServiceWorkerRegistration>& service_worker_registration, | 769 const scoped_refptr<ServiceWorkerRegistration>& service_worker_registration, |
| 780 int64 service_worker_id, | 770 int64 service_worker_id, |
| 781 const RegistrationKey& key, | 771 const RegistrationKey& key, |
| 782 BackgroundSyncRegistration::RegistrationId sync_registration_id, | 772 BackgroundSyncRegistration::RegistrationId sync_registration_id, |
| 783 ServiceWorkerStatusCode status_code) { | 773 ServiceWorkerStatusCode status_code) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 794 | 784 |
| 795 void BackgroundSyncManager::EventCompleteImpl( | 785 void BackgroundSyncManager::EventCompleteImpl( |
| 796 int64 service_worker_id, | 786 int64 service_worker_id, |
| 797 const RegistrationKey& key, | 787 const RegistrationKey& key, |
| 798 BackgroundSyncRegistration::RegistrationId sync_registration_id, | 788 BackgroundSyncRegistration::RegistrationId sync_registration_id, |
| 799 ServiceWorkerStatusCode status_code, | 789 ServiceWorkerStatusCode status_code, |
| 800 const base::Closure& callback) { | 790 const base::Closure& callback) { |
| 801 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 791 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 802 | 792 |
| 803 if (disabled_) { | 793 if (disabled_) { |
| 804 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 794 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); |
| 805 base::Bind(callback)); | |
| 806 return; | 795 return; |
| 807 } | 796 } |
| 808 | 797 |
| 809 BackgroundSyncRegistration* registration = | 798 BackgroundSyncRegistration* registration = |
| 810 LookupRegistration(service_worker_id, key); | 799 LookupRegistration(service_worker_id, key); |
| 811 if (!registration || registration->id != sync_registration_id) { | 800 if (!registration || registration->id != sync_registration_id) { |
| 812 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 801 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); |
| 813 base::Bind(callback)); | |
| 814 return; | 802 return; |
| 815 } | 803 } |
| 816 | 804 |
| 817 if (registration->periodicity == SYNC_ONE_SHOT) { | 805 if (registration->periodicity == SYNC_ONE_SHOT) { |
| 818 if (status_code != SERVICE_WORKER_OK) { | 806 if (status_code != SERVICE_WORKER_OK) { |
| 819 // TODO(jkarlin) Fire the sync event on the next page load controlled by | 807 // TODO(jkarlin) Fire the sync event on the next page load controlled by |
| 820 // this registration. (crbug.com/479665) | 808 // this registration. (crbug.com/479665) |
| 821 registration->sync_state = SYNC_STATE_FAILED; | 809 registration->sync_state = SYNC_STATE_FAILED; |
| 822 } else { | 810 } else { |
| 823 registration = nullptr; | 811 registration = nullptr; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 836 | 824 |
| 837 void BackgroundSyncManager::EventCompleteDidStore( | 825 void BackgroundSyncManager::EventCompleteDidStore( |
| 838 int64 service_worker_id, | 826 int64 service_worker_id, |
| 839 const base::Closure& callback, | 827 const base::Closure& callback, |
| 840 ServiceWorkerStatusCode status_code) { | 828 ServiceWorkerStatusCode status_code) { |
| 841 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 829 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 842 | 830 |
| 843 if (status_code == SERVICE_WORKER_ERROR_NOT_FOUND) { | 831 if (status_code == SERVICE_WORKER_ERROR_NOT_FOUND) { |
| 844 // The registration is gone. | 832 // The registration is gone. |
| 845 sw_to_registrations_map_.erase(service_worker_id); | 833 sw_to_registrations_map_.erase(service_worker_id); |
| 846 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 834 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); |
| 847 base::Bind(callback)); | |
| 848 return; | 835 return; |
| 849 } | 836 } |
| 850 | 837 |
| 851 if (status_code != SERVICE_WORKER_OK) { | 838 if (status_code != SERVICE_WORKER_OK) { |
| 852 LOG(ERROR) << "BackgroundSync failed to store registration due to backend " | 839 LOG(ERROR) << "BackgroundSync failed to store registration due to backend " |
| 853 "failure."; | 840 "failure."; |
| 854 DisableAndClearManager(base::Bind(callback)); | 841 DisableAndClearManager(base::Bind(callback)); |
| 855 return; | 842 return; |
| 856 } | 843 } |
| 857 | 844 |
| 858 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 845 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); |
| 859 base::Bind(callback)); | |
| 860 } | 846 } |
| 861 | 847 |
| 862 void BackgroundSyncManager::OnRegistrationDeletedImpl( | 848 void BackgroundSyncManager::OnRegistrationDeletedImpl( |
| 863 int64 registration_id, | 849 int64 registration_id, |
| 864 const base::Closure& callback) { | 850 const base::Closure& callback) { |
| 865 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 851 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 866 | 852 |
| 867 // The backend (ServiceWorkerStorage) will delete the data, so just delete the | 853 // The backend (ServiceWorkerStorage) will delete the data, so just delete the |
| 868 // memory representation here. | 854 // memory representation here. |
| 869 sw_to_registrations_map_.erase(registration_id); | 855 sw_to_registrations_map_.erase(registration_id); |
| 870 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 856 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); |
| 871 base::Bind(callback)); | |
| 872 } | 857 } |
| 873 | 858 |
| 874 void BackgroundSyncManager::OnStorageWipedImpl(const base::Closure& callback) { | 859 void BackgroundSyncManager::OnStorageWipedImpl(const base::Closure& callback) { |
| 875 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 860 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 876 | 861 |
| 877 sw_to_registrations_map_.clear(); | 862 sw_to_registrations_map_.clear(); |
| 878 disabled_ = false; | 863 disabled_ = false; |
| 879 InitImpl(callback); | 864 InitImpl(callback); |
| 880 } | 865 } |
| 881 | 866 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 BackgroundSyncManager::MakeStatusCompletion(const StatusCallback& callback) { | 919 BackgroundSyncManager::MakeStatusCompletion(const StatusCallback& callback) { |
| 935 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 920 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 936 | 921 |
| 937 return base::Bind( | 922 return base::Bind( |
| 938 &BackgroundSyncManager::CompleteOperationCallback<StatusCallback, | 923 &BackgroundSyncManager::CompleteOperationCallback<StatusCallback, |
| 939 ErrorType>, | 924 ErrorType>, |
| 940 weak_ptr_factory_.GetWeakPtr(), callback); | 925 weak_ptr_factory_.GetWeakPtr(), callback); |
| 941 } | 926 } |
| 942 | 927 |
| 943 } // namespace content | 928 } // namespace content |
| OLD | NEW |