| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 base::Bind(&SendPostMessageToWorkerOnMainThread, | 117 base::Bind(&SendPostMessageToWorkerOnMainThread, |
| 118 base::RetainedRef(thread_safe_sender_), | 118 base::RetainedRef(thread_safe_sender_), |
| 119 handle_ref_->handle_id(), provider_impl->provider_id(), | 119 handle_ref_->handle_id(), provider_impl->provider_id(), |
| 120 // We cast WebString to string16 before crossing | 120 // We cast WebString to string16 before crossing |
| 121 // threads for thread-safety. | 121 // threads for thread-safety. |
| 122 static_cast<base::string16>(message), | 122 static_cast<base::string16>(message), |
| 123 url::Origin(source_origin), | 123 url::Origin(source_origin), |
| 124 base::Passed(base::WrapUnique(channels)))); | 124 base::Passed(base::WrapUnique(channels)))); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void WebServiceWorkerImpl::setNavigationPreload( |
| 128 const blink::WebString& value, |
| 129 WebSetNavigationPreloadCallbacks* callback) { |
| 130 LOG(ERROR) << "WebServiceWorkerImpl::setNavigationPreload " << value.utf8(); |
| 131 ServiceWorkerDispatcher* dispatcher = |
| 132 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
| 133 DCHECK(dispatcher); |
| 134 dispatcher->SetNavigationPreload(handle_ref_->handle_id(), value.utf8(), |
| 135 callback); |
| 136 } |
| 137 |
| 138 void WebServiceWorkerImpl::getNavigationPreload( |
| 139 WebGetNavigationPreloadCallbacks* callback) { |
| 140 LOG(ERROR) << "WebServiceWorkerImpl::getNavigationPreload "; |
| 141 ServiceWorkerDispatcher* dispatcher = |
| 142 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
| 143 DCHECK(dispatcher); |
| 144 dispatcher->GetNavigationPreload(handle_ref_->handle_id(), callback); |
| 145 } |
| 146 |
| 127 void WebServiceWorkerImpl::terminate() { | 147 void WebServiceWorkerImpl::terminate() { |
| 128 thread_safe_sender_->Send( | 148 thread_safe_sender_->Send( |
| 129 new ServiceWorkerHostMsg_TerminateWorker(handle_ref_->handle_id())); | 149 new ServiceWorkerHostMsg_TerminateWorker(handle_ref_->handle_id())); |
| 130 } | 150 } |
| 131 | 151 |
| 132 // static | 152 // static |
| 133 std::unique_ptr<blink::WebServiceWorker::Handle> | 153 std::unique_ptr<blink::WebServiceWorker::Handle> |
| 134 WebServiceWorkerImpl::CreateHandle( | 154 WebServiceWorkerImpl::CreateHandle( |
| 135 const scoped_refptr<WebServiceWorkerImpl>& worker) { | 155 const scoped_refptr<WebServiceWorkerImpl>& worker) { |
| 136 if (!worker) | 156 if (!worker) |
| 137 return nullptr; | 157 return nullptr; |
| 138 return base::MakeUnique<HandleImpl>(worker); | 158 return base::MakeUnique<HandleImpl>(worker); |
| 139 } | 159 } |
| 140 | 160 |
| 141 WebServiceWorkerImpl::~WebServiceWorkerImpl() { | 161 WebServiceWorkerImpl::~WebServiceWorkerImpl() { |
| 142 ServiceWorkerDispatcher* dispatcher = | 162 ServiceWorkerDispatcher* dispatcher = |
| 143 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 163 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
| 144 if (dispatcher) | 164 if (dispatcher) |
| 145 dispatcher->RemoveServiceWorker(handle_ref_->handle_id()); | 165 dispatcher->RemoveServiceWorker(handle_ref_->handle_id()); |
| 146 } | 166 } |
| 147 | 167 |
| 148 } // namespace content | 168 } // namespace content |
| OLD | NEW |