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

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IndexedDBClient.cpp

Issue 1862223005: Add setIndexedDBClientCreateFunction() explanatory comment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 #include "wtf/Atomics.h"
7 7
8 namespace blink { 8 namespace blink {
9 9
10 static void* idbClientCreateFunction = nullptr; 10 static void* idbClientCreateFunction = nullptr;
11 11
12 void setIndexedDBClientCreateFunction(CreateIndexedDBClient createFunction) 12 void setIndexedDBClientCreateFunction(CreateIndexedDBClient createFunction)
13 { 13 {
14 // See web/IndexedDBClientImpl.h comment for some context. As the initializa tion
15 // of this IndexedDB client constructor now happens as context is set up for
16 // threads, it is possible that setIndexedDBClientCreateFunction() will be
17 // called more than once. Hence update atomicity is needed.
14 #if ENABLE(ASSERT) 18 #if ENABLE(ASSERT)
15 CreateIndexedDBClient* currentFunction = reinterpret_cast<CreateIndexedDBCli ent*>(acquireLoad(&idbClientCreateFunction)); 19 CreateIndexedDBClient* currentFunction = reinterpret_cast<CreateIndexedDBCli ent*>(acquireLoad(&idbClientCreateFunction));
16 ASSERT(!currentFunction || currentFunction == createFunction); 20 ASSERT(!currentFunction || currentFunction == createFunction);
17 #endif 21 #endif
18 releaseStore(&idbClientCreateFunction, reinterpret_cast<void*>(createFunctio n)); 22 releaseStore(&idbClientCreateFunction, reinterpret_cast<void*>(createFunctio n));
19 } 23 }
20 24
21 IndexedDBClient* IndexedDBClient::create() 25 IndexedDBClient* IndexedDBClient::create()
22 { 26 {
23 CreateIndexedDBClient* createFunction = reinterpret_cast<CreateIndexedDBClie nt*>(acquireLoad(&idbClientCreateFunction)); 27 CreateIndexedDBClient* createFunction = reinterpret_cast<CreateIndexedDBClie nt*>(acquireLoad(&idbClientCreateFunction));
24 ASSERT(createFunction); 28 ASSERT(createFunction);
25 // There's no reason why we need to allocate a new proxy each time, but 29 // There's no reason why we need to allocate a new proxy each time, but
26 // there's also no strong reason not to. 30 // there's also no strong reason not to.
27 return createFunction(); 31 return createFunction();
28 } 32 }
29 33
30 } // namespace blink 34 } // 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