| 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/indexeddb/IndexedDBClient.h" | 5 #include "modules/indexeddb/IndexedDBClient.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/workers/WorkerClients.h" | 10 #include "core/workers/WorkerClients.h" |
| 11 #include "core/workers/WorkerGlobalScope.h" | 11 #include "core/workers/WorkerGlobalScope.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 IndexedDBClient::IndexedDBClient() {} | 15 IndexedDBClient::IndexedDBClient(LocalFrame& frame) |
| 16 : Supplement<LocalFrame>(frame) {} |
| 17 |
| 18 IndexedDBClient::IndexedDBClient(WorkerClients& clients) |
| 19 : Supplement<WorkerClients>(clients) {} |
| 16 | 20 |
| 17 IndexedDBClient* IndexedDBClient::from(ExecutionContext* context) { | 21 IndexedDBClient* IndexedDBClient::from(ExecutionContext* context) { |
| 18 if (context->isDocument()) | 22 if (context->isDocument()) |
| 19 return static_cast<IndexedDBClient*>(Supplement<LocalFrame>::from( | 23 return static_cast<IndexedDBClient*>(Supplement<LocalFrame>::from( |
| 20 toDocument(*context).frame(), supplementName())); | 24 toDocument(*context).frame(), supplementName())); |
| 21 | 25 |
| 22 WorkerClients* clients = toWorkerGlobalScope(*context).clients(); | 26 WorkerClients* clients = toWorkerGlobalScope(*context).clients(); |
| 23 ASSERT(clients); | 27 ASSERT(clients); |
| 24 return static_cast<IndexedDBClient*>( | 28 return static_cast<IndexedDBClient*>( |
| 25 Supplement<WorkerClients>::from(clients, supplementName())); | 29 Supplement<WorkerClients>::from(clients, supplementName())); |
| 26 } | 30 } |
| 27 | 31 |
| 28 const char* IndexedDBClient::supplementName() { | 32 const char* IndexedDBClient::supplementName() { |
| 29 return "IndexedDBClient"; | 33 return "IndexedDBClient"; |
| 30 } | 34 } |
| 31 | 35 |
| 32 DEFINE_TRACE(IndexedDBClient) { | 36 DEFINE_TRACE(IndexedDBClient) { |
| 33 Supplement<LocalFrame>::trace(visitor); | 37 Supplement<LocalFrame>::trace(visitor); |
| 34 Supplement<WorkerClients>::trace(visitor); | 38 Supplement<WorkerClients>::trace(visitor); |
| 35 } | 39 } |
| 36 | 40 |
| 37 void provideIndexedDBClientTo(LocalFrame& frame, IndexedDBClient* client) { | 41 void provideIndexedDBClientTo(LocalFrame& frame, IndexedDBClient* client) { |
| 38 frame.provideSupplement(IndexedDBClient::supplementName(), client); | 42 Supplement<LocalFrame>::provideTo(frame, IndexedDBClient::supplementName(), |
| 43 client); |
| 39 } | 44 } |
| 40 | 45 |
| 41 void provideIndexedDBClientToWorker(WorkerClients* clients, | 46 void provideIndexedDBClientToWorker(WorkerClients* clients, |
| 42 IndexedDBClient* client) { | 47 IndexedDBClient* client) { |
| 43 clients->provideSupplement(IndexedDBClient::supplementName(), client); | 48 clients->provideSupplement(IndexedDBClient::supplementName(), client); |
| 44 } | 49 } |
| 45 | 50 |
| 46 } // namespace blink | 51 } // namespace blink |
| OLD | NEW |