Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(862)

Unified Diff: third_party/WebKit/Source/modules/indexeddb/IndexedDBClient.cpp

Issue 1865213006: Replace setIndexedDBClientCreateFunction madness with Supplements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify per review feedback Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/indexeddb/IndexedDBClient.cpp
diff --git a/third_party/WebKit/Source/modules/indexeddb/IndexedDBClient.cpp b/third_party/WebKit/Source/modules/indexeddb/IndexedDBClient.cpp
index 55478aab08ff6520c900dbed8931b8270fb78694..f8ddc1a47752a86fdbd827362edc2c489373b2c5 100644
--- a/third_party/WebKit/Source/modules/indexeddb/IndexedDBClient.cpp
+++ b/third_party/WebKit/Source/modules/indexeddb/IndexedDBClient.cpp
@@ -3,32 +3,42 @@
// found in the LICENSE file.
#include "modules/indexeddb/IndexedDBClient.h"
-#include "wtf/Atomics.h"
+
+#include "core/dom/Document.h"
+#include "core/dom/ExecutionContext.h"
+#include "core/frame/LocalFrame.h"
+#include "core/workers/WorkerClients.h"
+#include "core/workers/WorkerGlobalScope.h"
namespace blink {
-static void* idbClientCreateFunction = nullptr;
+IndexedDBClient::IndexedDBClient()
+{
+}
+
+IndexedDBClient* IndexedDBClient::from(ExecutionContext* context)
+{
+ if (context->isDocument())
+ return static_cast<IndexedDBClient*>(Supplement<LocalFrame>::from(toDocument(*context).frame(), supplementName()));
+
+ WorkerClients* clients = toWorkerGlobalScope(*context).clients();
+ ASSERT(clients);
+ return static_cast<IndexedDBClient*>(Supplement<WorkerClients>::from(clients, supplementName()));
+}
+
+const char* IndexedDBClient::supplementName()
+{
+ return "IndexedDBClient";
+}
-void setIndexedDBClientCreateFunction(CreateIndexedDBClient createFunction)
+void provideIndexedDBClientTo(LocalFrame& frame, IndexedDBClient* client)
{
- // See web/IndexedDBClientImpl.h comment for some context. As the initialization
- // of this IndexedDB client constructor now happens as context is set up for
- // threads, it is possible that setIndexedDBClientCreateFunction() will be
- // called more than once. Hence update atomicity is needed.
-#if ENABLE(ASSERT)
- CreateIndexedDBClient* currentFunction = reinterpret_cast<CreateIndexedDBClient*>(acquireLoad(&idbClientCreateFunction));
- ASSERT(!currentFunction || currentFunction == createFunction);
-#endif
- releaseStore(&idbClientCreateFunction, reinterpret_cast<void*>(createFunction));
+ frame.provideSupplement(IndexedDBClient::supplementName(), client);
}
-IndexedDBClient* IndexedDBClient::create()
+void provideIndexedDBClientToWorker(WorkerClients* clients, IndexedDBClient* client)
{
- CreateIndexedDBClient* createFunction = reinterpret_cast<CreateIndexedDBClient*>(acquireLoad(&idbClientCreateFunction));
- ASSERT(createFunction);
- // There's no reason why we need to allocate a new proxy each time, but
- // there's also no strong reason not to.
- return createFunction();
+ clients->provideSupplement(IndexedDBClient::supplementName(), client);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698