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

Side by Side Diff: content/renderer/service_worker/service_worker_context_client.cc

Issue 2106693002: Convert EmbeddedWorker to InterfaceRegistry/Provider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 months 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 | « content/renderer/service_worker/service_worker_context_client.h ('k') | no next file » | 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/renderer/service_worker/service_worker_context_client.h" 5 #include "content/renderer/service_worker/service_worker_context_client.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 IDMap<blink::WebServiceWorkerClientsClaimCallbacks, IDMapOwnPointer>; 169 IDMap<blink::WebServiceWorkerClientsClaimCallbacks, IDMapOwnPointer>;
170 using ClientCallbacksMap = 170 using ClientCallbacksMap =
171 IDMap<blink::WebServiceWorkerClientCallbacks, IDMapOwnPointer>; 171 IDMap<blink::WebServiceWorkerClientCallbacks, IDMapOwnPointer>;
172 using SkipWaitingCallbacksMap = 172 using SkipWaitingCallbacksMap =
173 IDMap<blink::WebServiceWorkerSkipWaitingCallbacks, IDMapOwnPointer>; 173 IDMap<blink::WebServiceWorkerSkipWaitingCallbacks, IDMapOwnPointer>;
174 using SyncEventCallbacksMap = 174 using SyncEventCallbacksMap =
175 IDMap<const base::Callback<void(blink::mojom::ServiceWorkerEventStatus)>, 175 IDMap<const base::Callback<void(blink::mojom::ServiceWorkerEventStatus)>,
176 IDMapOwnPointer>; 176 IDMapOwnPointer>;
177 177
178 explicit WorkerContextData(ServiceWorkerContextClient* owner) 178 explicit WorkerContextData(ServiceWorkerContextClient* owner)
179 : weak_factory(owner), proxy_weak_factory(owner->proxy_) {} 179 : interface_registry(nullptr),
180 weak_factory(owner),
181 proxy_weak_factory(owner->proxy_) {}
180 182
181 ~WorkerContextData() { 183 ~WorkerContextData() {
182 DCHECK(thread_checker.CalledOnValidThread()); 184 DCHECK(thread_checker.CalledOnValidThread());
183 } 185 }
184 186
185 // Pending callbacks for GetClientDocuments(). 187 // Pending callbacks for GetClientDocuments().
186 ClientsCallbacksMap clients_callbacks; 188 ClientsCallbacksMap clients_callbacks;
187 189
188 // Pending callbacks for OpenWindow() and FocusClient(). 190 // Pending callbacks for OpenWindow() and FocusClient().
189 ClientCallbacksMap client_callbacks; 191 ClientCallbacksMap client_callbacks;
190 192
191 // Pending callbacks for SkipWaiting(). 193 // Pending callbacks for SkipWaiting().
192 SkipWaitingCallbacksMap skip_waiting_callbacks; 194 SkipWaitingCallbacksMap skip_waiting_callbacks;
193 195
194 // Pending callbacks for ClaimClients(). 196 // Pending callbacks for ClaimClients().
195 ClaimClientsCallbacksMap claim_clients_callbacks; 197 ClaimClientsCallbacksMap claim_clients_callbacks;
196 198
197 // Pending callbacks for Background Sync Events 199 // Pending callbacks for Background Sync Events
198 SyncEventCallbacksMap sync_event_callbacks; 200 SyncEventCallbacksMap sync_event_callbacks;
199 201
200 ServiceRegistryImpl service_registry; 202 shell::InterfaceRegistry interface_registry;
203 shell::InterfaceProvider remote_interfaces;
201 204
202 base::ThreadChecker thread_checker; 205 base::ThreadChecker thread_checker;
203 base::WeakPtrFactory<ServiceWorkerContextClient> weak_factory; 206 base::WeakPtrFactory<ServiceWorkerContextClient> weak_factory;
204 base::WeakPtrFactory<blink::WebServiceWorkerContextProxy> proxy_weak_factory; 207 base::WeakPtrFactory<blink::WebServiceWorkerContextProxy> proxy_weak_factory;
205 }; 208 };
206 209
207 ServiceWorkerContextClient* 210 ServiceWorkerContextClient*
208 ServiceWorkerContextClient::ThreadSpecificInstance() { 211 ServiceWorkerContextClient::ThreadSpecificInstance() {
209 return g_worker_client_tls.Pointer()->Get(); 212 return g_worker_client_tls.Pointer()->Get();
210 } 213 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 OnNavigateClientError) 269 OnNavigateClientError)
267 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidSkipWaiting, OnDidSkipWaiting) 270 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidSkipWaiting, OnDidSkipWaiting)
268 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidClaimClients, OnDidClaimClients) 271 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidClaimClients, OnDidClaimClients)
269 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ClaimClientsError, OnClaimClientsError) 272 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ClaimClientsError, OnClaimClientsError)
270 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_Ping, OnPing); 273 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_Ping, OnPing);
271 IPC_MESSAGE_UNHANDLED(handled = false) 274 IPC_MESSAGE_UNHANDLED(handled = false)
272 IPC_END_MESSAGE_MAP() 275 IPC_END_MESSAGE_MAP()
273 DCHECK(handled); 276 DCHECK(handled);
274 } 277 }
275 278
276 void ServiceWorkerContextClient::BindServiceRegistry( 279 void ServiceWorkerContextClient::BindInterfaceProviders(
277 shell::mojom::InterfaceProviderRequest services, 280 shell::mojom::InterfaceProviderRequest request,
278 shell::mojom::InterfaceProviderPtr exposed_services) { 281 shell::mojom::InterfaceProviderPtr remote_interfaces) {
279 context_->service_registry.Bind(std::move(services)); 282 context_->interface_registry.Bind(std::move(request));
280 mojo::FuseInterface(context_->service_registry.TakeRemoteRequest(), 283 context_->remote_interfaces.Bind(std::move(remote_interfaces));
281 exposed_services.PassInterface());
282 } 284 }
283 285
284 blink::WebURL ServiceWorkerContextClient::scope() const { 286 blink::WebURL ServiceWorkerContextClient::scope() const {
285 return service_worker_scope_; 287 return service_worker_scope_;
286 } 288 }
287 289
288 void ServiceWorkerContextClient::getClient( 290 void ServiceWorkerContextClient::getClient(
289 const blink::WebString& id, 291 const blink::WebString& id,
290 blink::WebServiceWorkerClientCallbacks* callbacks) { 292 blink::WebServiceWorkerClientCallbacks* callbacks) {
291 DCHECK(callbacks); 293 DCHECK(callbacks);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 // willDestroyWorkerContext. 371 // willDestroyWorkerContext.
370 context_.reset(new WorkerContextData(this)); 372 context_.reset(new WorkerContextData(this));
371 373
372 ServiceWorkerRegistrationObjectInfo registration_info; 374 ServiceWorkerRegistrationObjectInfo registration_info;
373 ServiceWorkerVersionAttributes version_attrs; 375 ServiceWorkerVersionAttributes version_attrs;
374 provider_context_->GetAssociatedRegistration(&registration_info, 376 provider_context_->GetAssociatedRegistration(&registration_info,
375 &version_attrs); 377 &version_attrs);
376 DCHECK_NE(registration_info.registration_id, 378 DCHECK_NE(registration_info.registration_id,
377 kInvalidServiceWorkerRegistrationId); 379 kInvalidServiceWorkerRegistrationId);
378 380
379 // Register Mojo services. 381 // Register Mojo interfaces.
380 context_->service_registry.ServiceRegistry::AddService( 382 context_->interface_registry.AddInterface(
381 base::Bind(&BackgroundSyncClientImpl::Create)); 383 base::Bind(&BackgroundSyncClientImpl::Create));
382 384
383 SetRegistrationInServiceWorkerGlobalScope(registration_info, version_attrs); 385 SetRegistrationInServiceWorkerGlobalScope(registration_info, version_attrs);
384 386
385 Send(new EmbeddedWorkerHostMsg_WorkerThreadStarted( 387 Send(new EmbeddedWorkerHostMsg_WorkerThreadStarted(
386 embedded_worker_id_, WorkerThread::GetCurrentId(), 388 embedded_worker_id_, WorkerThread::GetCurrentId(),
387 provider_context_->provider_id())); 389 provider_context_->provider_id()));
388 390
389 TRACE_EVENT_ASYNC_STEP_INTO0( 391 TRACE_EVENT_ASYNC_STEP_INTO0(
390 "ServiceWorker", 392 "ServiceWorker",
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 } 1026 }
1025 1027
1026 base::WeakPtr<ServiceWorkerContextClient> 1028 base::WeakPtr<ServiceWorkerContextClient>
1027 ServiceWorkerContextClient::GetWeakPtr() { 1029 ServiceWorkerContextClient::GetWeakPtr() {
1028 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); 1030 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread());
1029 DCHECK(context_); 1031 DCHECK(context_);
1030 return context_->weak_factory.GetWeakPtr(); 1032 return context_->weak_factory.GetWeakPtr();
1031 } 1033 }
1032 1034
1033 } // namespace content 1035 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/service_worker/service_worker_context_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698