| 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 <map> | 7 #include <map> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 worker_task_runner_->PostTask( | 743 worker_task_runner_->PostTask( |
| 744 FROM_HERE, base::Bind(&ServiceWorkerContextClient::SendWorkerStarted, | 744 FROM_HERE, base::Bind(&ServiceWorkerContextClient::SendWorkerStarted, |
| 745 GetWeakPtr())); | 745 GetWeakPtr())); |
| 746 } | 746 } |
| 747 | 747 |
| 748 void ServiceWorkerContextClient::DidInitializeWorkerContext( | 748 void ServiceWorkerContextClient::DidInitializeWorkerContext( |
| 749 v8::Local<v8::Context> context) { | 749 v8::Local<v8::Context> context) { |
| 750 GetContentClient() | 750 GetContentClient() |
| 751 ->renderer() | 751 ->renderer() |
| 752 ->DidInitializeServiceWorkerContextOnWorkerThread( | 752 ->DidInitializeServiceWorkerContextOnWorkerThread( |
| 753 context, service_worker_version_id_, script_url_); | 753 context, service_worker_version_id_, service_worker_scope_, |
| 754 script_url_); |
| 754 } | 755 } |
| 755 | 756 |
| 756 void ServiceWorkerContextClient::WillDestroyWorkerContext( | 757 void ServiceWorkerContextClient::WillDestroyWorkerContext( |
| 757 v8::Local<v8::Context> context) { | 758 v8::Local<v8::Context> context) { |
| 758 // At this point WillStopCurrentWorkerThread is already called, so | 759 // At this point WillStopCurrentWorkerThread is already called, so |
| 759 // worker_task_runner_->RunsTasksInCurrentSequence() returns false | 760 // worker_task_runner_->RunsTasksInCurrentSequence() returns false |
| 760 // (while we're still on the worker thread). | 761 // (while we're still on the worker thread). |
| 761 proxy_ = NULL; | 762 proxy_ = NULL; |
| 762 | 763 |
| 763 // Aborts all the pending events callbacks. | 764 // Aborts all the pending events callbacks. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 777 | 778 |
| 778 // We have to clear callbacks now, as they need to be freed on the | 779 // We have to clear callbacks now, as they need to be freed on the |
| 779 // same thread. | 780 // same thread. |
| 780 context_.reset(); | 781 context_.reset(); |
| 781 | 782 |
| 782 // This also lets the message filter stop dispatching messages to | 783 // This also lets the message filter stop dispatching messages to |
| 783 // this client. | 784 // this client. |
| 784 g_worker_client_tls.Pointer()->Set(NULL); | 785 g_worker_client_tls.Pointer()->Set(NULL); |
| 785 | 786 |
| 786 GetContentClient()->renderer()->WillDestroyServiceWorkerContextOnWorkerThread( | 787 GetContentClient()->renderer()->WillDestroyServiceWorkerContextOnWorkerThread( |
| 787 context, service_worker_version_id_, script_url_); | 788 context, service_worker_version_id_, service_worker_scope_, script_url_); |
| 788 } | 789 } |
| 789 | 790 |
| 790 void ServiceWorkerContextClient::WorkerContextDestroyed() { | 791 void ServiceWorkerContextClient::WorkerContextDestroyed() { |
| 791 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); | 792 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); |
| 792 | 793 |
| 793 // TODO(shimazu): The signals to the browser should be in the order: | 794 // TODO(shimazu): The signals to the browser should be in the order: |
| 794 // (1) WorkerStopped (via mojo call EmbeddedWorkerInstanceHost.OnStopped()) | 795 // (1) WorkerStopped (via mojo call EmbeddedWorkerInstanceHost.OnStopped()) |
| 795 // (2) ProviderDestroyed (via mojo call | 796 // (2) ProviderDestroyed (via mojo call |
| 796 // ServiceWorkerDispatcherHost.OnProviderDestroyed()), this is triggered by | 797 // ServiceWorkerDispatcherHost.OnProviderDestroyed()), this is triggered by |
| 797 // the following EmbeddedWorkerInstanceClientImpl::WorkerContextDestroyed(), | 798 // the following EmbeddedWorkerInstanceClientImpl::WorkerContextDestroyed(), |
| (...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1688 } | 1689 } |
| 1689 | 1690 |
| 1690 base::WeakPtr<ServiceWorkerContextClient> | 1691 base::WeakPtr<ServiceWorkerContextClient> |
| 1691 ServiceWorkerContextClient::GetWeakPtr() { | 1692 ServiceWorkerContextClient::GetWeakPtr() { |
| 1692 DCHECK(worker_task_runner_->RunsTasksInCurrentSequence()); | 1693 DCHECK(worker_task_runner_->RunsTasksInCurrentSequence()); |
| 1693 DCHECK(context_); | 1694 DCHECK(context_); |
| 1694 return context_->weak_factory.GetWeakPtr(); | 1695 return context_->weak_factory.GetWeakPtr(); |
| 1695 } | 1696 } |
| 1696 | 1697 |
| 1697 } // namespace content | 1698 } // namespace content |
| OLD | NEW |