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 #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 |
OLD | NEW |