Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: content/browser/background_sync/background_sync_manager.cc

Issue 2490623005: Remove InterfaceRegistry/Provider from service workers (Closed)
Patch Set: rebase/fix comment Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/service_worker/embedded_worker_instance.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/time/time.h" 16 #include "base/time/time.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "content/browser/background_sync/background_sync_metrics.h" 18 #include "content/browser/background_sync/background_sync_metrics.h"
19 #include "content/browser/background_sync/background_sync_network_observer.h" 19 #include "content/browser/background_sync/background_sync_network_observer.h"
20 #include "content/browser/background_sync/background_sync_registration_options.h " 20 #include "content/browser/background_sync/background_sync_registration_options.h "
21 #include "content/browser/service_worker/embedded_worker_status.h" 21 #include "content/browser/service_worker/embedded_worker_status.h"
22 #include "content/browser/service_worker/service_worker_context_wrapper.h" 22 #include "content/browser/service_worker/service_worker_context_wrapper.h"
23 #include "content/browser/service_worker/service_worker_storage.h" 23 #include "content/browser/service_worker/service_worker_storage.h"
24 #include "content/browser/storage_partition_impl.h" 24 #include "content/browser/storage_partition_impl.h"
25 #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h"
25 #include "content/common/service_worker/service_worker_type_converters.h" 26 #include "content/common/service_worker/service_worker_type_converters.h"
27 #include "content/common/service_worker/service_worker_utils.h"
26 #include "content/public/browser/background_sync_controller.h" 28 #include "content/public/browser/background_sync_controller.h"
27 #include "content/public/browser/browser_context.h" 29 #include "content/public/browser/browser_context.h"
28 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/permission_manager.h" 31 #include "content/public/browser/permission_manager.h"
30 #include "content/public/browser/permission_type.h" 32 #include "content/public/browser/permission_type.h"
31 33
32 #if defined(OS_ANDROID) 34 #if defined(OS_ANDROID)
33 #include "content/browser/android/background_sync_network_observer_android.h" 35 #include "content/browser/android/background_sync_network_observer_android.h"
34 #endif 36 #endif
35 37
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 return parameters; 143 return parameters;
142 } 144 }
143 145
144 background_sync_controller->GetParameterOverrides(parameters.get()); 146 background_sync_controller->GetParameterOverrides(parameters.get());
145 return parameters; 147 return parameters;
146 } 148 }
147 149
148 void OnSyncEventFinished(scoped_refptr<ServiceWorkerVersion> active_version, 150 void OnSyncEventFinished(scoped_refptr<ServiceWorkerVersion> active_version,
149 int request_id, 151 int request_id,
150 const ServiceWorkerVersion::StatusCallback& callback, 152 const ServiceWorkerVersion::StatusCallback& callback,
151 blink::mojom::ServiceWorkerEventStatus status, 153 ServiceWorkerStatusCode status,
152 base::Time dispatch_event_time) { 154 base::Time dispatch_event_time) {
153 if (!active_version->FinishRequest( 155 if (!active_version->FinishRequest(request_id, status == SERVICE_WORKER_OK,
154 request_id, 156 dispatch_event_time)) {
155 status == blink::mojom::ServiceWorkerEventStatus::COMPLETED,
156 dispatch_event_time)) {
157 return; 157 return;
158 } 158 }
159 callback.Run(mojo::ConvertTo<ServiceWorkerStatusCode>(status)); 159 callback.Run(status);
160 } 160 }
161 161
162 } // namespace 162 } // namespace
163 163
164 BackgroundSyncManager::BackgroundSyncRegistrations:: 164 BackgroundSyncManager::BackgroundSyncRegistrations::
165 BackgroundSyncRegistrations() 165 BackgroundSyncRegistrations()
166 : next_id(BackgroundSyncRegistration::kInitialId) { 166 : next_id(BackgroundSyncRegistration::kInitialId) {
167 } 167 }
168 168
169 BackgroundSyncManager::BackgroundSyncRegistrations::BackgroundSyncRegistrations( 169 BackgroundSyncManager::BackgroundSyncRegistrations::BackgroundSyncRegistrations(
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 weak_ptr_factory_.GetWeakPtr(), tag, active_version, 759 weak_ptr_factory_.GetWeakPtr(), tag, active_version,
760 last_chance, callback), 760 last_chance, callback),
761 callback); 761 callback);
762 return; 762 return;
763 } 763 }
764 764
765 int request_id = active_version->StartRequestWithCustomTimeout( 765 int request_id = active_version->StartRequestWithCustomTimeout(
766 ServiceWorkerMetrics::EventType::SYNC, callback, 766 ServiceWorkerMetrics::EventType::SYNC, callback,
767 parameters_->max_sync_event_duration, 767 parameters_->max_sync_event_duration,
768 ServiceWorkerVersion::CONTINUE_ON_TIMEOUT); 768 ServiceWorkerVersion::CONTINUE_ON_TIMEOUT);
769 base::WeakPtr<blink::mojom::BackgroundSyncServiceClient> client =
770 active_version
771 ->GetMojoServiceForRequest<blink::mojom::BackgroundSyncServiceClient>(
772 request_id);
773 769
774 client->Sync(tag, last_chance, 770 active_version->event_dispatcher()->DispatchSyncEvent(
775 base::Bind(&OnSyncEventFinished, std::move(active_version), 771 tag, last_chance,
776 request_id, callback)); 772 base::Bind(&OnSyncEventFinished, std::move(active_version), request_id,
773 callback));
777 } 774 }
778 775
779 void BackgroundSyncManager::ScheduleDelayedTask(const base::Closure& callback, 776 void BackgroundSyncManager::ScheduleDelayedTask(const base::Closure& callback,
780 base::TimeDelta delay) { 777 base::TimeDelta delay) {
781 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(FROM_HERE, callback, 778 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(FROM_HERE, callback,
782 delay); 779 delay);
783 } 780 }
784 781
785 void BackgroundSyncManager::HasMainFrameProviderHost( 782 void BackgroundSyncManager::HasMainFrameProviderHost(
786 const GURL& origin, 783 const GURL& origin,
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 parameters_->max_sync_attempts = max_attempts; 1171 parameters_->max_sync_attempts = max_attempts;
1175 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); 1172 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback);
1176 } 1173 }
1177 1174
1178 base::Closure BackgroundSyncManager::MakeEmptyCompletion() { 1175 base::Closure BackgroundSyncManager::MakeEmptyCompletion() {
1179 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1176 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1180 return op_scheduler_.WrapCallbackToRunNext(base::Bind(&base::DoNothing)); 1177 return op_scheduler_.WrapCallbackToRunNext(base::Bind(&base::DoNothing));
1181 } 1178 }
1182 1179
1183 } // namespace content 1180 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/embedded_worker_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698