OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "modules/ModulesExport.h" | 36 #include "modules/ModulesExport.h" |
37 #include "modules/indexeddb/IDBDatabaseCallbacks.h" | 37 #include "modules/indexeddb/IDBDatabaseCallbacks.h" |
38 #include "modules/indexeddb/IDBHistograms.h" | 38 #include "modules/indexeddb/IDBHistograms.h" |
39 #include "modules/indexeddb/IDBMetadata.h" | 39 #include "modules/indexeddb/IDBMetadata.h" |
40 #include "modules/indexeddb/IDBObjectStore.h" | 40 #include "modules/indexeddb/IDBObjectStore.h" |
41 #include "modules/indexeddb/IDBObjectStoreParameters.h" | 41 #include "modules/indexeddb/IDBObjectStoreParameters.h" |
42 #include "modules/indexeddb/IDBTransaction.h" | 42 #include "modules/indexeddb/IDBTransaction.h" |
43 #include "modules/indexeddb/IndexedDB.h" | 43 #include "modules/indexeddb/IndexedDB.h" |
44 #include "platform/heap/Handle.h" | 44 #include "platform/heap/Handle.h" |
45 #include "public/platform/modules/indexeddb/WebIDBDatabase.h" | 45 #include "public/platform/modules/indexeddb/WebIDBDatabase.h" |
46 #include "wtf/OwnPtr.h" | |
47 #include "wtf/PassOwnPtr.h" | |
48 #include "wtf/PassRefPtr.h" | 46 #include "wtf/PassRefPtr.h" |
49 #include "wtf/RefPtr.h" | 47 #include "wtf/RefPtr.h" |
| 48 #include <memory> |
50 | 49 |
51 namespace blink { | 50 namespace blink { |
52 | 51 |
53 class DOMException; | 52 class DOMException; |
54 class ExceptionState; | 53 class ExceptionState; |
55 class ExecutionContext; | 54 class ExecutionContext; |
56 | 55 |
57 class MODULES_EXPORT IDBDatabase final | 56 class MODULES_EXPORT IDBDatabase final |
58 : public EventTargetWithInlineData | 57 : public EventTargetWithInlineData |
59 , public ActiveScriptWrappable | 58 , public ActiveScriptWrappable |
60 , public ActiveDOMObject { | 59 , public ActiveDOMObject { |
61 USING_GARBAGE_COLLECTED_MIXIN(IDBDatabase); | 60 USING_GARBAGE_COLLECTED_MIXIN(IDBDatabase); |
62 DEFINE_WRAPPERTYPEINFO(); | 61 DEFINE_WRAPPERTYPEINFO(); |
63 public: | 62 public: |
64 static IDBDatabase* create(ExecutionContext*, PassOwnPtr<WebIDBDatabase>, ID
BDatabaseCallbacks*); | 63 static IDBDatabase* create(ExecutionContext*, std::unique_ptr<WebIDBDatabase
>, IDBDatabaseCallbacks*); |
65 ~IDBDatabase() override; | 64 ~IDBDatabase() override; |
66 DECLARE_VIRTUAL_TRACE(); | 65 DECLARE_VIRTUAL_TRACE(); |
67 | 66 |
68 void setMetadata(const IDBDatabaseMetadata& metadata) { m_metadata = metadat
a; } | 67 void setMetadata(const IDBDatabaseMetadata& metadata) { m_metadata = metadat
a; } |
69 void indexCreated(int64_t objectStoreId, const IDBIndexMetadata&); | 68 void indexCreated(int64_t objectStoreId, const IDBIndexMetadata&); |
70 void indexDeleted(int64_t objectStoreId, int64_t indexId); | 69 void indexDeleted(int64_t objectStoreId, int64_t indexId); |
71 void transactionCreated(IDBTransaction*); | 70 void transactionCreated(IDBTransaction*); |
72 void transactionFinished(const IDBTransaction*); | 71 void transactionFinished(const IDBTransaction*); |
73 | 72 |
74 // Implement the IDL | 73 // Implement the IDL |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 static const char transactionReadOnlyErrorMessage[]; | 132 static const char transactionReadOnlyErrorMessage[]; |
134 static const char databaseClosedErrorMessage[]; | 133 static const char databaseClosedErrorMessage[]; |
135 | 134 |
136 static void recordApiCallsHistogram(IndexedDatabaseMethods); | 135 static void recordApiCallsHistogram(IndexedDatabaseMethods); |
137 | 136 |
138 protected: | 137 protected: |
139 // EventTarget | 138 // EventTarget |
140 DispatchEventResult dispatchEventInternal(Event*) override; | 139 DispatchEventResult dispatchEventInternal(Event*) override; |
141 | 140 |
142 private: | 141 private: |
143 IDBDatabase(ExecutionContext*, PassOwnPtr<WebIDBDatabase>, IDBDatabaseCallba
cks*); | 142 IDBDatabase(ExecutionContext*, std::unique_ptr<WebIDBDatabase>, IDBDatabaseC
allbacks*); |
144 | 143 |
145 IDBObjectStore* createObjectStore(const String& name, const IDBKeyPath&, boo
l autoIncrement, ExceptionState&); | 144 IDBObjectStore* createObjectStore(const String& name, const IDBKeyPath&, boo
l autoIncrement, ExceptionState&); |
146 void closeConnection(); | 145 void closeConnection(); |
147 | 146 |
148 IDBDatabaseMetadata m_metadata; | 147 IDBDatabaseMetadata m_metadata; |
149 OwnPtr<WebIDBDatabase> m_backend; | 148 std::unique_ptr<WebIDBDatabase> m_backend; |
150 Member<IDBTransaction> m_versionChangeTransaction; | 149 Member<IDBTransaction> m_versionChangeTransaction; |
151 HeapHashMap<int64_t, Member<IDBTransaction>> m_transactions; | 150 HeapHashMap<int64_t, Member<IDBTransaction>> m_transactions; |
152 | 151 |
153 bool m_closePending = false; | 152 bool m_closePending = false; |
154 bool m_contextStopped = false; | 153 bool m_contextStopped = false; |
155 | 154 |
156 // Keep track of the versionchange events waiting to be fired on this | 155 // Keep track of the versionchange events waiting to be fired on this |
157 // database so that we can cancel them if the database closes. | 156 // database so that we can cancel them if the database closes. |
158 HeapVector<Member<Event>> m_enqueuedEvents; | 157 HeapVector<Member<Event>> m_enqueuedEvents; |
159 | 158 |
160 Member<IDBDatabaseCallbacks> m_databaseCallbacks; | 159 Member<IDBDatabaseCallbacks> m_databaseCallbacks; |
161 }; | 160 }; |
162 | 161 |
163 } // namespace blink | 162 } // namespace blink |
164 | 163 |
165 #endif // IDBDatabase_h | 164 #endif // IDBDatabase_h |
OLD | NEW |