| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "modules/serviceworkers/ServiceWorkerContainerClient.h" | 5 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/dom/ExecutionContext.h" | 8 #include "core/dom/ExecutionContext.h" |
| 9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 10 #include "core/loader/FrameLoaderClient.h" | 10 #include "core/loader/FrameLoaderClient.h" |
| 11 #include "core/workers/WorkerGlobalScope.h" | 11 #include "core/workers/WorkerGlobalScope.h" |
| 12 #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h" | 12 #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h" |
| 13 #include <memory> |
| 13 | 14 |
| 14 namespace blink { | 15 namespace blink { |
| 15 | 16 |
| 16 ServiceWorkerContainerClient* ServiceWorkerContainerClient::create(PassOwnPtr<We
bServiceWorkerProvider> provider) | 17 ServiceWorkerContainerClient* ServiceWorkerContainerClient::create(std::unique_p
tr<WebServiceWorkerProvider> provider) |
| 17 { | 18 { |
| 18 return new ServiceWorkerContainerClient(std::move(provider)); | 19 return new ServiceWorkerContainerClient(std::move(provider)); |
| 19 } | 20 } |
| 20 | 21 |
| 21 ServiceWorkerContainerClient::ServiceWorkerContainerClient(PassOwnPtr<WebService
WorkerProvider> provider) | 22 ServiceWorkerContainerClient::ServiceWorkerContainerClient(std::unique_ptr<WebSe
rviceWorkerProvider> provider) |
| 22 : m_provider(std::move(provider)) | 23 : m_provider(std::move(provider)) |
| 23 { | 24 { |
| 24 } | 25 } |
| 25 | 26 |
| 26 ServiceWorkerContainerClient::~ServiceWorkerContainerClient() | 27 ServiceWorkerContainerClient::~ServiceWorkerContainerClient() |
| 27 { | 28 { |
| 28 } | 29 } |
| 29 | 30 |
| 30 const char* ServiceWorkerContainerClient::supplementName() | 31 const char* ServiceWorkerContainerClient::supplementName() |
| 31 { | 32 { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 44 return nullptr; | 45 return nullptr; |
| 45 | 46 |
| 46 ServiceWorkerContainerClient* client = static_cast<ServiceWorkerContainerCli
ent*>(Supplement<Document>::from(document, supplementName())); | 47 ServiceWorkerContainerClient* client = static_cast<ServiceWorkerContainerCli
ent*>(Supplement<Document>::from(document, supplementName())); |
| 47 if (!client) { | 48 if (!client) { |
| 48 client = new ServiceWorkerContainerClient(document->frame()->loader().cl
ient()->createServiceWorkerProvider()); | 49 client = new ServiceWorkerContainerClient(document->frame()->loader().cl
ient()->createServiceWorkerProvider()); |
| 49 Supplement<Document>::provideTo(*document, supplementName(), client); | 50 Supplement<Document>::provideTo(*document, supplementName(), client); |
| 50 } | 51 } |
| 51 return client; | 52 return client; |
| 52 } | 53 } |
| 53 | 54 |
| 54 void provideServiceWorkerContainerClientToWorker(WorkerClients* clients, PassOwn
Ptr<WebServiceWorkerProvider> provider) | 55 void provideServiceWorkerContainerClientToWorker(WorkerClients* clients, std::un
ique_ptr<WebServiceWorkerProvider> provider) |
| 55 { | 56 { |
| 56 clients->provideSupplement(ServiceWorkerContainerClient::supplementName(), S
erviceWorkerContainerClient::create(std::move(provider))); | 57 clients->provideSupplement(ServiceWorkerContainerClient::supplementName(), S
erviceWorkerContainerClient::create(std::move(provider))); |
| 57 } | 58 } |
| 58 | 59 |
| 59 } // namespace blink | 60 } // namespace blink |
| OLD | NEW |