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

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

Issue 1862403002: Avoid setIndexedDBClientCreateFunction() write race. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix assert condition 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 78f0ecaf2a365ef53694a2210685a709c977d6f0..54f9f5eba241df40b4cf95ba9bff6c4cf9c0d317 100644
--- a/third_party/WebKit/Source/modules/indexeddb/IndexedDBClient.cpp
+++ b/third_party/WebKit/Source/modules/indexeddb/IndexedDBClient.cpp
@@ -3,14 +3,19 @@
// found in the LICENSE file.
#include "modules/indexeddb/IndexedDBClient.h"
+#include "wtf/Atomics.h"
namespace blink {
-static CreateIndexedDBClient* idbClientCreateFunction = nullptr;
+static void* idbClientCreateFunction = nullptr;
void setIndexedDBClientCreateFunction(CreateIndexedDBClient createFunction)
{
- idbClientCreateFunction = createFunction;
+#if ENABLE(ASSERT)
+ CreateIndexedDBClient* currentFunction = reinterpret_cast<CreateIndexedDBClient*>(acquireLoad(&idbClientCreateFunction));
+ ASSERT(!currentFunction || currentFunction == createFunction);
+#endif
+ releaseStore(&idbClientCreateFunction, reinterpret_cast<void*>(createFunction));
}
IndexedDBClient* IndexedDBClient::create()
@@ -18,7 +23,7 @@ IndexedDBClient* IndexedDBClient::create()
ASSERT(idbClientCreateFunction);
// There's no reason why we need to allocate a new proxy each time, but
// there's also no strong reason not to.
- return idbClientCreateFunction();
+ return reinterpret_cast<CreateIndexedDBClient*>(idbClientCreateFunction)();
}
} // namespace blink
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698