| 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 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 worker_task_runner_->PostTask( | 737 worker_task_runner_->PostTask( |
| 738 FROM_HERE, base::Bind(&ServiceWorkerContextClient::SendWorkerStarted, | 738 FROM_HERE, base::Bind(&ServiceWorkerContextClient::SendWorkerStarted, |
| 739 GetWeakPtr())); | 739 GetWeakPtr())); |
| 740 } | 740 } |
| 741 | 741 |
| 742 void ServiceWorkerContextClient::DidInitializeWorkerContext( | 742 void ServiceWorkerContextClient::DidInitializeWorkerContext( |
| 743 v8::Local<v8::Context> context) { | 743 v8::Local<v8::Context> context) { |
| 744 GetContentClient() | 744 GetContentClient() |
| 745 ->renderer() | 745 ->renderer() |
| 746 ->DidInitializeServiceWorkerContextOnWorkerThread( | 746 ->DidInitializeServiceWorkerContextOnWorkerThread( |
| 747 context, service_worker_version_id_, script_url_); | 747 context, service_worker_version_id_, service_worker_scope_, |
| 748 script_url_); |
| 748 } | 749 } |
| 749 | 750 |
| 750 void ServiceWorkerContextClient::WillDestroyWorkerContext( | 751 void ServiceWorkerContextClient::WillDestroyWorkerContext( |
| 751 v8::Local<v8::Context> context) { | 752 v8::Local<v8::Context> context) { |
| 752 // At this point WillStopCurrentWorkerThread is already called, so | 753 // At this point WillStopCurrentWorkerThread is already called, so |
| 753 // worker_task_runner_->RunsTasksInCurrentSequence() returns false | 754 // worker_task_runner_->RunsTasksInCurrentSequence() returns false |
| 754 // (while we're still on the worker thread). | 755 // (while we're still on the worker thread). |
| 755 proxy_ = NULL; | 756 proxy_ = NULL; |
| 756 | 757 |
| 757 // Aborts all the pending events callbacks. | 758 // Aborts all the pending events callbacks. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 771 | 772 |
| 772 // We have to clear callbacks now, as they need to be freed on the | 773 // We have to clear callbacks now, as they need to be freed on the |
| 773 // same thread. | 774 // same thread. |
| 774 context_.reset(); | 775 context_.reset(); |
| 775 | 776 |
| 776 // This also lets the message filter stop dispatching messages to | 777 // This also lets the message filter stop dispatching messages to |
| 777 // this client. | 778 // this client. |
| 778 g_worker_client_tls.Pointer()->Set(NULL); | 779 g_worker_client_tls.Pointer()->Set(NULL); |
| 779 | 780 |
| 780 GetContentClient()->renderer()->WillDestroyServiceWorkerContextOnWorkerThread( | 781 GetContentClient()->renderer()->WillDestroyServiceWorkerContextOnWorkerThread( |
| 781 context, service_worker_version_id_, script_url_); | 782 context, service_worker_version_id_, service_worker_scope_, script_url_); |
| 782 } | 783 } |
| 783 | 784 |
| 784 void ServiceWorkerContextClient::WorkerContextDestroyed() { | 785 void ServiceWorkerContextClient::WorkerContextDestroyed() { |
| 785 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); | 786 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); |
| 786 | 787 |
| 787 // TODO(shimazu): The signals to the browser should be in the order: | 788 // TODO(shimazu): The signals to the browser should be in the order: |
| 788 // (1) WorkerStopped (via mojo call EmbeddedWorkerInstanceHost.OnStopped()) | 789 // (1) WorkerStopped (via mojo call EmbeddedWorkerInstanceHost.OnStopped()) |
| 789 // (2) ProviderDestroyed (via mojo call | 790 // (2) ProviderDestroyed (via mojo call |
| 790 // ServiceWorkerDispatcherHost.OnProviderDestroyed()), this is triggered by | 791 // ServiceWorkerDispatcherHost.OnProviderDestroyed()), this is triggered by |
| 791 // the following EmbeddedWorkerInstanceClientImpl::WorkerContextDestroyed(), | 792 // the following EmbeddedWorkerInstanceClientImpl::WorkerContextDestroyed(), |
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 } | 1697 } |
| 1697 | 1698 |
| 1698 base::WeakPtr<ServiceWorkerContextClient> | 1699 base::WeakPtr<ServiceWorkerContextClient> |
| 1699 ServiceWorkerContextClient::GetWeakPtr() { | 1700 ServiceWorkerContextClient::GetWeakPtr() { |
| 1700 DCHECK(worker_task_runner_->RunsTasksInCurrentSequence()); | 1701 DCHECK(worker_task_runner_->RunsTasksInCurrentSequence()); |
| 1701 DCHECK(context_); | 1702 DCHECK(context_); |
| 1702 return context_->weak_factory.GetWeakPtr(); | 1703 return context_->weak_factory.GetWeakPtr(); |
| 1703 } | 1704 } |
| 1704 | 1705 |
| 1705 } // namespace content | 1706 } // namespace content |
| OLD | NEW |