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

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

Issue 1307133003: ServiceWorker: Make APIs that return ServiceWorkerRegistration coin a new JS object (2/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 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 "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 if (!found) 664 if (!found)
665 return; // Cannot be associated with a registration in some tests. 665 return; // Cannot be associated with a registration in some tests.
666 666
667 ServiceWorkerDispatcher* dispatcher = 667 ServiceWorkerDispatcher* dispatcher =
668 ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance( 668 ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance(
669 sender_.get(), main_thread_task_runner_.get()); 669 sender_.get(), main_thread_task_runner_.get());
670 670
671 // Register a registration and its version attributes with the dispatcher 671 // Register a registration and its version attributes with the dispatcher
672 // living on the worker thread. 672 // living on the worker thread.
673 scoped_ptr<WebServiceWorkerRegistrationImpl> registration( 673 scoped_ptr<WebServiceWorkerRegistrationImpl> registration(
674 dispatcher->CreateServiceWorkerRegistration(info, false)); 674 dispatcher->CreateRegistration(info, attrs, false));
675 registration->SetInstalling(
676 dispatcher->GetServiceWorker(attrs.installing, false));
677 registration->SetWaiting(
678 dispatcher->GetServiceWorker(attrs.waiting, false));
679 registration->SetActive(
680 dispatcher->GetServiceWorker(attrs.active, false));
681
682 proxy_->setRegistration(registration.release()); 675 proxy_->setRegistration(registration.release());
683 } 676 }
684 677
685 void ServiceWorkerContextClient::OnActivateEvent(int request_id) { 678 void ServiceWorkerContextClient::OnActivateEvent(int request_id) {
686 TRACE_EVENT0("ServiceWorker", 679 TRACE_EVENT0("ServiceWorker",
687 "ServiceWorkerContextClient::OnActivateEvent"); 680 "ServiceWorkerContextClient::OnActivateEvent");
688 proxy_->dispatchActivateEvent(request_id); 681 proxy_->dispatchActivateEvent(request_id);
689 } 682 }
690 683
691 void ServiceWorkerContextClient::OnInstallEvent(int request_id) { 684 void ServiceWorkerContextClient::OnInstallEvent(int request_id) {
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 } 960 }
968 961
969 base::WeakPtr<ServiceWorkerContextClient> 962 base::WeakPtr<ServiceWorkerContextClient>
970 ServiceWorkerContextClient::GetWeakPtr() { 963 ServiceWorkerContextClient::GetWeakPtr() {
971 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); 964 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread());
972 DCHECK(context_); 965 DCHECK(context_);
973 return context_->weak_factory.GetWeakPtr(); 966 return context_->weak_factory.GetWeakPtr();
974 } 967 }
975 968
976 } // namespace content 969 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698