| OLD | NEW |
| 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/child/service_worker/web_service_worker_impl.h" | 5 #include "content/child/service_worker/web_service_worker_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 using blink::WebMessagePortChannel; | 22 using blink::WebMessagePortChannel; |
| 23 using blink::WebMessagePortChannelArray; | 23 using blink::WebMessagePortChannelArray; |
| 24 using blink::WebMessagePortChannelClient; | 24 using blink::WebMessagePortChannelClient; |
| 25 using blink::WebSecurityOrigin; | 25 using blink::WebSecurityOrigin; |
| 26 using blink::WebString; | 26 using blink::WebString; |
| 27 | 27 |
| 28 namespace content { | 28 namespace content { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 class HandleImpl : public blink::WebServiceWorker::Handle { | 32 class SWHandleImpl : public blink::WebServiceWorker::Handle { |
| 33 public: | 33 public: |
| 34 explicit HandleImpl(const scoped_refptr<WebServiceWorkerImpl>& worker) | 34 explicit SWHandleImpl(const scoped_refptr<WebServiceWorkerImpl>& worker) |
| 35 : worker_(worker) {} | 35 : worker_(worker) {} |
| 36 ~HandleImpl() override {} | 36 ~SWHandleImpl() override {} |
| 37 | 37 |
| 38 blink::WebServiceWorker* ServiceWorker() override { return worker_.get(); } | 38 blink::WebServiceWorker* ServiceWorker() override { return worker_.get(); } |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 scoped_refptr<WebServiceWorkerImpl> worker_; | 41 scoped_refptr<WebServiceWorkerImpl> worker_; |
| 42 | 42 |
| 43 DISALLOW_COPY_AND_ASSIGN(HandleImpl); | 43 DISALLOW_COPY_AND_ASSIGN(SWHandleImpl); |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 } // namespace | 46 } // namespace |
| 47 | 47 |
| 48 WebServiceWorkerImpl::WebServiceWorkerImpl( | 48 WebServiceWorkerImpl::WebServiceWorkerImpl( |
| 49 std::unique_ptr<ServiceWorkerHandleReference> handle_ref, | 49 std::unique_ptr<ServiceWorkerHandleReference> handle_ref, |
| 50 ThreadSafeSender* thread_safe_sender) | 50 ThreadSafeSender* thread_safe_sender) |
| 51 : handle_ref_(std::move(handle_ref)), | 51 : handle_ref_(std::move(handle_ref)), |
| 52 state_(handle_ref_->state()), | 52 state_(handle_ref_->state()), |
| 53 thread_safe_sender_(thread_safe_sender), | 53 thread_safe_sender_(thread_safe_sender), |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 thread_safe_sender_->Send( | 101 thread_safe_sender_->Send( |
| 102 new ServiceWorkerHostMsg_TerminateWorker(handle_ref_->handle_id())); | 102 new ServiceWorkerHostMsg_TerminateWorker(handle_ref_->handle_id())); |
| 103 } | 103 } |
| 104 | 104 |
| 105 // static | 105 // static |
| 106 std::unique_ptr<blink::WebServiceWorker::Handle> | 106 std::unique_ptr<blink::WebServiceWorker::Handle> |
| 107 WebServiceWorkerImpl::CreateHandle( | 107 WebServiceWorkerImpl::CreateHandle( |
| 108 const scoped_refptr<WebServiceWorkerImpl>& worker) { | 108 const scoped_refptr<WebServiceWorkerImpl>& worker) { |
| 109 if (!worker) | 109 if (!worker) |
| 110 return nullptr; | 110 return nullptr; |
| 111 return base::MakeUnique<HandleImpl>(worker); | 111 return base::MakeUnique<SWHandleImpl>(worker); |
| 112 } | 112 } |
| 113 | 113 |
| 114 WebServiceWorkerImpl::~WebServiceWorkerImpl() { | 114 WebServiceWorkerImpl::~WebServiceWorkerImpl() { |
| 115 ServiceWorkerDispatcher* dispatcher = | 115 ServiceWorkerDispatcher* dispatcher = |
| 116 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 116 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
| 117 if (dispatcher) | 117 if (dispatcher) |
| 118 dispatcher->RemoveServiceWorker(handle_ref_->handle_id()); | 118 dispatcher->RemoveServiceWorker(handle_ref_->handle_id()); |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace content | 121 } // namespace content |
| OLD | NEW |