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 "content/browser/background_sync/background_sync_network_observer.h" | 9 #include "content/browser/background_sync/background_sync_network_observer.h" |
10 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 10 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 ServiceWorkerStatusCode status) { | 307 ServiceWorkerStatusCode status) { |
308 if (status != SERVICE_WORKER_OK || user_data.empty()) { | 308 if (status != SERVICE_WORKER_OK || user_data.empty()) { |
309 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); | 309 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); |
310 return; | 310 return; |
311 } | 311 } |
312 | 312 |
313 base::Closure barrier_closure = | 313 base::Closure barrier_closure = |
314 base::BarrierClosure(user_data.size(), base::Bind(callback)); | 314 base::BarrierClosure(user_data.size(), base::Bind(callback)); |
315 | 315 |
316 for (const auto& sw_id_and_regs : user_data) { | 316 for (const auto& sw_id_and_regs : user_data) { |
317 service_worker_context_->context()->storage()->ClearUserData( | 317 service_worker_context_->ClearRegistrationUserData( |
318 sw_id_and_regs.first, kBackgroundSyncUserDataKey, | 318 sw_id_and_regs.first, kBackgroundSyncUserDataKey, |
319 base::Bind(&BackgroundSyncManager::DisableAndClearManagerClearedOne, | 319 base::Bind(&BackgroundSyncManager::DisableAndClearManagerClearedOne, |
320 weak_ptr_factory_.GetWeakPtr(), barrier_closure)); | 320 weak_ptr_factory_.GetWeakPtr(), barrier_closure)); |
321 } | 321 } |
322 } | 322 } |
323 | 323 |
324 void BackgroundSyncManager::DisableAndClearManagerClearedOne( | 324 void BackgroundSyncManager::DisableAndClearManagerClearedOne( |
325 const base::Closure& barrier_closure, | 325 const base::Closure& barrier_closure, |
326 ServiceWorkerStatusCode status) { | 326 ServiceWorkerStatusCode status) { |
327 // The status doesn't matter at this point, there is nothing else to be done. | 327 // The status doesn't matter at this point, there is nothing else to be done. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 RegistrationKey registration_key(sync_registration); | 432 RegistrationKey registration_key(sync_registration); |
433 registrations->registration_map[registration_key] = sync_registration; | 433 registrations->registration_map[registration_key] = sync_registration; |
434 } | 434 } |
435 | 435 |
436 void BackgroundSyncManager::StoreDataInBackend( | 436 void BackgroundSyncManager::StoreDataInBackend( |
437 int64 sw_registration_id, | 437 int64 sw_registration_id, |
438 const GURL& origin, | 438 const GURL& origin, |
439 const std::string& backend_key, | 439 const std::string& backend_key, |
440 const std::string& data, | 440 const std::string& data, |
441 const ServiceWorkerStorage::StatusCallback& callback) { | 441 const ServiceWorkerStorage::StatusCallback& callback) { |
442 service_worker_context_->context()->storage()->StoreUserData( | 442 service_worker_context_->StoreRegistrationUserData( |
443 sw_registration_id, origin, backend_key, data, callback); | 443 sw_registration_id, origin, backend_key, data, callback); |
444 } | 444 } |
445 | 445 |
446 void BackgroundSyncManager::GetDataFromBackend( | 446 void BackgroundSyncManager::GetDataFromBackend( |
447 const std::string& backend_key, | 447 const std::string& backend_key, |
448 const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& | 448 const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& |
449 callback) { | 449 callback) { |
450 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 450 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
451 | 451 |
452 service_worker_context_->context()->storage()->GetUserDataForAllRegistrations( | 452 service_worker_context_->GetUserDataForAllRegistrations(backend_key, |
453 backend_key, callback); | 453 callback); |
454 } | 454 } |
455 | 455 |
456 void BackgroundSyncManager::UnregisterImpl( | 456 void BackgroundSyncManager::UnregisterImpl( |
457 const GURL& origin, | 457 const GURL& origin, |
458 int64 sw_registration_id, | 458 int64 sw_registration_id, |
459 const RegistrationKey& registration_key, | 459 const RegistrationKey& registration_key, |
460 BackgroundSyncRegistration::RegistrationId sync_registration_id, | 460 BackgroundSyncRegistration::RegistrationId sync_registration_id, |
461 const StatusCallback& callback) { | 461 const StatusCallback& callback) { |
462 if (disabled_) { | 462 if (disabled_) { |
463 base::MessageLoop::current()->PostTask( | 463 base::MessageLoop::current()->PostTask( |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 weak_ptr_factory_.GetWeakPtr(), callback); | 593 weak_ptr_factory_.GetWeakPtr(), callback); |
594 } | 594 } |
595 | 595 |
596 BackgroundSyncManager::StatusCallback | 596 BackgroundSyncManager::StatusCallback |
597 BackgroundSyncManager::MakeStatusCompletion(const StatusCallback& callback) { | 597 BackgroundSyncManager::MakeStatusCompletion(const StatusCallback& callback) { |
598 return base::Bind(&BackgroundSyncManager::PendingStatusCallback, | 598 return base::Bind(&BackgroundSyncManager::PendingStatusCallback, |
599 weak_ptr_factory_.GetWeakPtr(), callback); | 599 weak_ptr_factory_.GetWeakPtr(), callback); |
600 } | 600 } |
601 | 601 |
602 } // namespace content | 602 } // namespace content |
OLD | NEW |