| 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/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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 if (!found) | 670 if (!found) |
| 671 return; // Cannot be associated with a registration in some tests. | 671 return; // Cannot be associated with a registration in some tests. |
| 672 | 672 |
| 673 ServiceWorkerDispatcher* dispatcher = | 673 ServiceWorkerDispatcher* dispatcher = |
| 674 ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance( | 674 ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance( |
| 675 sender_.get(), main_thread_task_runner_.get()); | 675 sender_.get(), main_thread_task_runner_.get()); |
| 676 | 676 |
| 677 // Register a registration and its version attributes with the dispatcher | 677 // Register a registration and its version attributes with the dispatcher |
| 678 // living on the worker thread. | 678 // living on the worker thread. |
| 679 scoped_ptr<WebServiceWorkerRegistrationImpl> registration( | 679 scoped_ptr<WebServiceWorkerRegistrationImpl> registration( |
| 680 dispatcher->CreateServiceWorkerRegistration(info, false)); | 680 dispatcher->CreateRegistration(info, attrs)); |
| 681 registration->SetInstalling( | |
| 682 dispatcher->GetServiceWorker(attrs.installing, false)); | |
| 683 registration->SetWaiting( | |
| 684 dispatcher->GetServiceWorker(attrs.waiting, false)); | |
| 685 registration->SetActive( | |
| 686 dispatcher->GetServiceWorker(attrs.active, false)); | |
| 687 | |
| 688 proxy_->setRegistration(registration.release()); | 681 proxy_->setRegistration(registration.release()); |
| 689 } | 682 } |
| 690 | 683 |
| 691 void ServiceWorkerContextClient::OnActivateEvent(int request_id) { | 684 void ServiceWorkerContextClient::OnActivateEvent(int request_id) { |
| 692 TRACE_EVENT0("ServiceWorker", | 685 TRACE_EVENT0("ServiceWorker", |
| 693 "ServiceWorkerContextClient::OnActivateEvent"); | 686 "ServiceWorkerContextClient::OnActivateEvent"); |
| 694 proxy_->dispatchActivateEvent(request_id); | 687 proxy_->dispatchActivateEvent(request_id); |
| 695 } | 688 } |
| 696 | 689 |
| 697 void ServiceWorkerContextClient::OnInstallEvent(int request_id) { | 690 void ServiceWorkerContextClient::OnInstallEvent(int request_id) { |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 } | 966 } |
| 974 | 967 |
| 975 base::WeakPtr<ServiceWorkerContextClient> | 968 base::WeakPtr<ServiceWorkerContextClient> |
| 976 ServiceWorkerContextClient::GetWeakPtr() { | 969 ServiceWorkerContextClient::GetWeakPtr() { |
| 977 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 970 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
| 978 DCHECK(context_); | 971 DCHECK(context_); |
| 979 return context_->weak_factory.GetWeakPtr(); | 972 return context_->weak_factory.GetWeakPtr(); |
| 980 } | 973 } |
| 981 | 974 |
| 982 } // namespace content | 975 } // namespace content |
| OLD | NEW |