| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/barrier_closure.h" | 9 #include "base/barrier_closure.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "base/time/default_clock.h" | 15 #include "base/time/default_clock.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "content/browser/background_sync/background_sync_metrics.h" | 17 #include "content/browser/background_sync/background_sync_metrics.h" |
| 18 #include "content/browser/background_sync/background_sync_network_observer.h" | 18 #include "content/browser/background_sync/background_sync_network_observer.h" |
| 19 #include "content/browser/background_sync/background_sync_registration_options.h
" | 19 #include "content/browser/background_sync/background_sync_registration_options.h
" |
| 20 #include "content/browser/service_worker/embedded_worker_status.h" |
| 20 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 21 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 21 #include "content/browser/service_worker/service_worker_storage.h" | 22 #include "content/browser/service_worker/service_worker_storage.h" |
| 22 #include "content/browser/storage_partition_impl.h" | 23 #include "content/browser/storage_partition_impl.h" |
| 23 #include "content/common/service_worker/service_worker_type_converters.h" | 24 #include "content/common/service_worker/service_worker_type_converters.h" |
| 24 #include "content/public/browser/background_sync_controller.h" | 25 #include "content/public/browser/background_sync_controller.h" |
| 25 #include "content/public/browser/browser_context.h" | 26 #include "content/public/browser/browser_context.h" |
| 26 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 27 #include "content/public/browser/permission_manager.h" | 28 #include "content/public/browser/permission_manager.h" |
| 28 #include "content/public/browser/permission_type.h" | 29 #include "content/public/browser/permission_type.h" |
| 29 | 30 |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 } | 749 } |
| 749 | 750 |
| 750 void BackgroundSyncManager::DispatchSyncEvent( | 751 void BackgroundSyncManager::DispatchSyncEvent( |
| 751 const std::string& tag, | 752 const std::string& tag, |
| 752 scoped_refptr<ServiceWorkerVersion> active_version, | 753 scoped_refptr<ServiceWorkerVersion> active_version, |
| 753 blink::mojom::BackgroundSyncEventLastChance last_chance, | 754 blink::mojom::BackgroundSyncEventLastChance last_chance, |
| 754 const ServiceWorkerVersion::StatusCallback& callback) { | 755 const ServiceWorkerVersion::StatusCallback& callback) { |
| 755 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 756 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 756 DCHECK(active_version); | 757 DCHECK(active_version); |
| 757 | 758 |
| 758 if (active_version->running_status() != ServiceWorkerVersion::RUNNING) { | 759 if (active_version->running_status() != EmbeddedWorkerStatus::RUNNING) { |
| 759 active_version->RunAfterStartWorker( | 760 active_version->RunAfterStartWorker( |
| 760 ServiceWorkerMetrics::EventType::SYNC, | 761 ServiceWorkerMetrics::EventType::SYNC, |
| 761 base::Bind(&BackgroundSyncManager::DispatchSyncEvent, | 762 base::Bind(&BackgroundSyncManager::DispatchSyncEvent, |
| 762 weak_ptr_factory_.GetWeakPtr(), tag, active_version, | 763 weak_ptr_factory_.GetWeakPtr(), tag, active_version, |
| 763 last_chance, callback), | 764 last_chance, callback), |
| 764 callback); | 765 callback); |
| 765 return; | 766 return; |
| 766 } | 767 } |
| 767 | 768 |
| 768 int request_id = active_version->StartRequestWithCustomTimeout( | 769 int request_id = active_version->StartRequestWithCustomTimeout( |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1256 BackgroundSyncManager::MakeStatusCompletion(const StatusCallback& callback) { | 1257 BackgroundSyncManager::MakeStatusCompletion(const StatusCallback& callback) { |
| 1257 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1258 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 1258 | 1259 |
| 1259 return base::Bind( | 1260 return base::Bind( |
| 1260 &BackgroundSyncManager::CompleteOperationCallback<StatusCallback, | 1261 &BackgroundSyncManager::CompleteOperationCallback<StatusCallback, |
| 1261 BackgroundSyncStatus>, | 1262 BackgroundSyncStatus>, |
| 1262 weak_ptr_factory_.GetWeakPtr(), callback); | 1263 weak_ptr_factory_.GetWeakPtr(), callback); |
| 1263 } | 1264 } |
| 1264 | 1265 |
| 1265 } // namespace content | 1266 } // namespace content |
| OLD | NEW |