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" |
(...skipping 19 matching lines...) Expand all Loading... |
30 const char* ServiceWorkerContainerClient::supplementName() | 30 const char* ServiceWorkerContainerClient::supplementName() |
31 { | 31 { |
32 return "ServiceWorkerContainerClient"; | 32 return "ServiceWorkerContainerClient"; |
33 } | 33 } |
34 | 34 |
35 ServiceWorkerContainerClient* ServiceWorkerContainerClient::from(ExecutionContex
t* context) | 35 ServiceWorkerContainerClient* ServiceWorkerContainerClient::from(ExecutionContex
t* context) |
36 { | 36 { |
37 if (context->isWorkerGlobalScope()) { | 37 if (context->isWorkerGlobalScope()) { |
38 WorkerClients* clients = toWorkerGlobalScope(context)->clients(); | 38 WorkerClients* clients = toWorkerGlobalScope(context)->clients(); |
39 ASSERT(clients); | 39 ASSERT(clients); |
40 return static_cast<ServiceWorkerContainerClient*>(HeapSupplement<WorkerC
lients>::from(clients, supplementName())); | 40 return static_cast<ServiceWorkerContainerClient*>(Supplement<WorkerClien
ts>::from(clients, supplementName())); |
41 } | 41 } |
42 Document* document = toDocument(context); | 42 Document* document = toDocument(context); |
43 if (!document->frame()) | 43 if (!document->frame()) |
44 return nullptr; | 44 return nullptr; |
45 | 45 |
46 ServiceWorkerContainerClient* client = static_cast<ServiceWorkerContainerCli
ent*>(HeapSupplement<Document>::from(document, supplementName())); | 46 ServiceWorkerContainerClient* client = static_cast<ServiceWorkerContainerCli
ent*>(Supplement<Document>::from(document, supplementName())); |
47 if (!client) { | 47 if (!client) { |
48 client = new ServiceWorkerContainerClient(document->frame()->loader().cl
ient()->createServiceWorkerProvider()); | 48 client = new ServiceWorkerContainerClient(document->frame()->loader().cl
ient()->createServiceWorkerProvider()); |
49 HeapSupplement<Document>::provideTo(*document, supplementName(), client)
; | 49 Supplement<Document>::provideTo(*document, supplementName(), client); |
50 } | 50 } |
51 return client; | 51 return client; |
52 } | 52 } |
53 | 53 |
54 void provideServiceWorkerContainerClientToWorker(WorkerClients* clients, PassOwn
Ptr<WebServiceWorkerProvider> provider) | 54 void provideServiceWorkerContainerClientToWorker(WorkerClients* clients, PassOwn
Ptr<WebServiceWorkerProvider> provider) |
55 { | 55 { |
56 clients->provideSupplement(ServiceWorkerContainerClient::supplementName(), S
erviceWorkerContainerClient::create(provider)); | 56 clients->provideSupplement(ServiceWorkerContainerClient::supplementName(), S
erviceWorkerContainerClient::create(provider)); |
57 } | 57 } |
58 | 58 |
59 } // namespace blink | 59 } // namespace blink |
OLD | NEW |