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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "wtf/Atomics.h"
6 7
7 namespace blink { 8 namespace blink {
8 9
9 static CreateIndexedDBClient* idbClientCreateFunction = nullptr; 10 static void* idbClientCreateFunction = nullptr;
10 11
11 void setIndexedDBClientCreateFunction(CreateIndexedDBClient createFunction) 12 void setIndexedDBClientCreateFunction(CreateIndexedDBClient createFunction)
12 { 13 {
13 idbClientCreateFunction = createFunction; 14 #if ENABLE(ASSERT)
15 CreateIndexedDBClient* currentFunction = reinterpret_cast<CreateIndexedDBCli ent*>(acquireLoad(&idbClientCreateFunction));
16 ASSERT(!currentFunction || currentFunction == createFunction);
17 #endif
18 releaseStore(&idbClientCreateFunction, reinterpret_cast<void*>(createFunctio n));
14 } 19 }
15 20
16 IndexedDBClient* IndexedDBClient::create() 21 IndexedDBClient* IndexedDBClient::create()
17 { 22 {
18 ASSERT(idbClientCreateFunction); 23 ASSERT(idbClientCreateFunction);
19 // There's no reason why we need to allocate a new proxy each time, but 24 // There's no reason why we need to allocate a new proxy each time, but
20 // there's also no strong reason not to. 25 // there's also no strong reason not to.
21 return idbClientCreateFunction(); 26 return reinterpret_cast<CreateIndexedDBClient*>(idbClientCreateFunction)();
22 } 27 }
23 28
24 } // namespace blink 29 } // namespace blink
OLDNEW
« 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