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

Side by Side Diff: content/browser/service_worker/service_worker_dispatcher_host.cc

Issue 849163002: ServiceWorker: Expose registration within ServiceWorkerGlobalScope [2/3] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove TODO comment about forwarding messages Created 5 years, 11 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/service_worker/service_worker_dispatcher_host.h" 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/message_port_message_filter.h" 10 #include "content/browser/message_port_message_filter.h"
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 ServiceWorkerProviderHost* provider_host = 545 ServiceWorkerProviderHost* provider_host =
546 GetContext()->GetProviderHost(render_process_id_, provider_id); 546 GetContext()->GetProviderHost(render_process_id_, provider_id);
547 if (!provider_host) { 547 if (!provider_host) {
548 BadMessageReceived(); 548 BadMessageReceived();
549 return; 549 return;
550 } 550 }
551 if (!provider_host->IsContextAlive()) 551 if (!provider_host->IsContextAlive())
552 return; 552 return;
553 if (!provider_host->SetHostedVersionId(version_id)) 553 if (!provider_host->SetHostedVersionId(version_id))
554 BadMessageReceived(); 554 BadMessageReceived();
555
556 // Retrieve the registration associated with |version_id|.
557 ServiceWorkerVersion* version = GetContext()->GetLiveVersion(version_id);
558 if (!version)
559 return;
560 ServiceWorkerRegistration* registration =
561 GetContext()->GetLiveRegistration(version->registration_id());
562 DCHECK(registration);
563
564 ServiceWorkerRegistrationObjectInfo info;
565 ServiceWorkerVersionAttributes attrs;
566 GetRegistrationObjectInfoAndVersionAttributes(
567 provider_id, registration, &info, &attrs);
568
569 Send(new ServiceWorkerMsg_AssociateRegistrationWithServiceWorker(
570 kDocumentMainThreadId, provider_id, info, attrs));
555 } 571 }
556 572
557 ServiceWorkerRegistrationHandle* 573 ServiceWorkerRegistrationHandle*
558 ServiceWorkerDispatcherHost::FindRegistrationHandle(int provider_id, 574 ServiceWorkerDispatcherHost::FindRegistrationHandle(int provider_id,
559 int64 registration_id) { 575 int64 registration_id) {
560 for (IDMap<ServiceWorkerRegistrationHandle, IDMapOwnPointer>::iterator 576 for (IDMap<ServiceWorkerRegistrationHandle, IDMapOwnPointer>::iterator
561 iter(&registration_handles_); 577 iter(&registration_handles_);
562 !iter.IsAtEnd(); 578 !iter.IsAtEnd();
563 iter.Advance()) { 579 iter.Advance()) {
564 ServiceWorkerRegistrationHandle* handle = iter.GetCurrentValue(); 580 ServiceWorkerRegistrationHandle* handle = iter.GetCurrentValue();
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 handles_.AddWithID(handle.release(), handle_id); 930 handles_.AddWithID(handle.release(), handle_id);
915 } 931 }
916 932
917 void ServiceWorkerDispatcherHost::RegisterServiceWorkerRegistrationHandle( 933 void ServiceWorkerDispatcherHost::RegisterServiceWorkerRegistrationHandle(
918 scoped_ptr<ServiceWorkerRegistrationHandle> handle) { 934 scoped_ptr<ServiceWorkerRegistrationHandle> handle) {
919 int handle_id = handle->handle_id(); 935 int handle_id = handle->handle_id();
920 registration_handles_.AddWithID(handle.release(), handle_id); 936 registration_handles_.AddWithID(handle.release(), handle_id);
921 } 937 }
922 938
923 } // namespace content 939 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698