| 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(LocalFrame& frame) | 15 IndexedDBClient::IndexedDBClient(LocalFrame& frame) |
| 16 : Supplement<LocalFrame>(frame) {} | 16 : Supplement<LocalFrame>(frame) {} |
| 17 | 17 |
| 18 IndexedDBClient::IndexedDBClient(WorkerClients& clients) | 18 IndexedDBClient::IndexedDBClient(WorkerClients& clients) |
| 19 : Supplement<WorkerClients>(clients) {} | 19 : Supplement<WorkerClients>(clients) {} |
| 20 | 20 |
| 21 IndexedDBClient* IndexedDBClient::From(ExecutionContext* context) { | 21 IndexedDBClient* IndexedDBClient::From(ExecutionContext* context) { |
| 22 if (context->IsDocument()) | 22 if (context->IsDocument()) |
| 23 return static_cast<IndexedDBClient*>(Supplement<LocalFrame>::From( | 23 return static_cast<IndexedDBClient*>(Supplement<LocalFrame>::From( |
| 24 ToDocument(*context).GetFrame(), SupplementName())); | 24 ToDocument(*context).GetFrame(), SupplementName())); |
| 25 | 25 |
| 26 WorkerClients* clients = ToWorkerGlobalScope(*context).Clients(); | 26 WorkerClients* clients = ToWorkerGlobalScope(*context).Clients(); |
| 27 ASSERT(clients); | 27 DCHECK(clients); |
| 28 return static_cast<IndexedDBClient*>( | 28 return static_cast<IndexedDBClient*>( |
| 29 Supplement<WorkerClients>::From(clients, SupplementName())); | 29 Supplement<WorkerClients>::From(clients, SupplementName())); |
| 30 } | 30 } |
| 31 | 31 |
| 32 const char* IndexedDBClient::SupplementName() { | 32 const char* IndexedDBClient::SupplementName() { |
| 33 return "IndexedDBClient"; | 33 return "IndexedDBClient"; |
| 34 } | 34 } |
| 35 | 35 |
| 36 DEFINE_TRACE(IndexedDBClient) { | 36 DEFINE_TRACE(IndexedDBClient) { |
| 37 Supplement<LocalFrame>::Trace(visitor); | 37 Supplement<LocalFrame>::Trace(visitor); |
| 38 Supplement<WorkerClients>::Trace(visitor); | 38 Supplement<WorkerClients>::Trace(visitor); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void ProvideIndexedDBClientTo(LocalFrame& frame, IndexedDBClient* client) { | 41 void ProvideIndexedDBClientTo(LocalFrame& frame, IndexedDBClient* client) { |
| 42 Supplement<LocalFrame>::ProvideTo(frame, IndexedDBClient::SupplementName(), | 42 Supplement<LocalFrame>::ProvideTo(frame, IndexedDBClient::SupplementName(), |
| 43 client); | 43 client); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void ProvideIndexedDBClientToWorker(WorkerClients* clients, | 46 void ProvideIndexedDBClientToWorker(WorkerClients* clients, |
| 47 IndexedDBClient* client) { | 47 IndexedDBClient* client) { |
| 48 clients->ProvideSupplement(IndexedDBClient::SupplementName(), client); | 48 clients->ProvideSupplement(IndexedDBClient::SupplementName(), client); |
| 49 } | 49 } |
| 50 | 50 |
| 51 } // namespace blink | 51 } // namespace blink |
| OLD | NEW |