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" |
46 #include "wtf/PassRefPtr.h" | 48 #include "wtf/PassRefPtr.h" |
47 #include "wtf/RefPtr.h" | 49 #include "wtf/RefPtr.h" |
48 #include <memory> | |
49 | 50 |
50 namespace blink { | 51 namespace blink { |
51 | 52 |
52 class DOMException; | 53 class DOMException; |
53 class ExceptionState; | 54 class ExceptionState; |
54 class ExecutionContext; | 55 class ExecutionContext; |
55 | 56 |
56 class MODULES_EXPORT IDBDatabase final | 57 class MODULES_EXPORT IDBDatabase final |
57 : public EventTargetWithInlineData | 58 : public EventTargetWithInlineData |
58 , public ActiveScriptWrappable | 59 , public ActiveScriptWrappable |
59 , public ActiveDOMObject { | 60 , public ActiveDOMObject { |
60 USING_GARBAGE_COLLECTED_MIXIN(IDBDatabase); | 61 USING_GARBAGE_COLLECTED_MIXIN(IDBDatabase); |
61 DEFINE_WRAPPERTYPEINFO(); | 62 DEFINE_WRAPPERTYPEINFO(); |
62 public: | 63 public: |
63 static IDBDatabase* create(ExecutionContext*, std::unique_ptr<WebIDBDatabase
>, IDBDatabaseCallbacks*); | 64 static IDBDatabase* create(ExecutionContext*, PassOwnPtr<WebIDBDatabase>, ID
BDatabaseCallbacks*); |
64 ~IDBDatabase() override; | 65 ~IDBDatabase() override; |
65 DECLARE_VIRTUAL_TRACE(); | 66 DECLARE_VIRTUAL_TRACE(); |
66 | 67 |
67 void setMetadata(const IDBDatabaseMetadata& metadata) { m_metadata = metadat
a; } | 68 void setMetadata(const IDBDatabaseMetadata& metadata) { m_metadata = metadat
a; } |
68 void indexCreated(int64_t objectStoreId, const IDBIndexMetadata&); | 69 void indexCreated(int64_t objectStoreId, const IDBIndexMetadata&); |
69 void indexDeleted(int64_t objectStoreId, int64_t indexId); | 70 void indexDeleted(int64_t objectStoreId, int64_t indexId); |
70 void transactionCreated(IDBTransaction*); | 71 void transactionCreated(IDBTransaction*); |
71 void transactionFinished(const IDBTransaction*); | 72 void transactionFinished(const IDBTransaction*); |
72 | 73 |
73 // Implement the IDL | 74 // Implement the IDL |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 static const char transactionReadOnlyErrorMessage[]; | 133 static const char transactionReadOnlyErrorMessage[]; |
133 static const char databaseClosedErrorMessage[]; | 134 static const char databaseClosedErrorMessage[]; |
134 | 135 |
135 static void recordApiCallsHistogram(IndexedDatabaseMethods); | 136 static void recordApiCallsHistogram(IndexedDatabaseMethods); |
136 | 137 |
137 protected: | 138 protected: |
138 // EventTarget | 139 // EventTarget |
139 DispatchEventResult dispatchEventInternal(Event*) override; | 140 DispatchEventResult dispatchEventInternal(Event*) override; |
140 | 141 |
141 private: | 142 private: |
142 IDBDatabase(ExecutionContext*, std::unique_ptr<WebIDBDatabase>, IDBDatabaseC
allbacks*); | 143 IDBDatabase(ExecutionContext*, PassOwnPtr<WebIDBDatabase>, IDBDatabaseCallba
cks*); |
143 | 144 |
144 IDBObjectStore* createObjectStore(const String& name, const IDBKeyPath&, boo
l autoIncrement, ExceptionState&); | 145 IDBObjectStore* createObjectStore(const String& name, const IDBKeyPath&, boo
l autoIncrement, ExceptionState&); |
145 void closeConnection(); | 146 void closeConnection(); |
146 | 147 |
147 IDBDatabaseMetadata m_metadata; | 148 IDBDatabaseMetadata m_metadata; |
148 std::unique_ptr<WebIDBDatabase> m_backend; | 149 OwnPtr<WebIDBDatabase> m_backend; |
149 Member<IDBTransaction> m_versionChangeTransaction; | 150 Member<IDBTransaction> m_versionChangeTransaction; |
150 HeapHashMap<int64_t, Member<IDBTransaction>> m_transactions; | 151 HeapHashMap<int64_t, Member<IDBTransaction>> m_transactions; |
151 | 152 |
152 bool m_closePending = false; | 153 bool m_closePending = false; |
153 bool m_contextStopped = false; | 154 bool m_contextStopped = false; |
154 | 155 |
155 // Keep track of the versionchange events waiting to be fired on this | 156 // Keep track of the versionchange events waiting to be fired on this |
156 // database so that we can cancel them if the database closes. | 157 // database so that we can cancel them if the database closes. |
157 HeapVector<Member<Event>> m_enqueuedEvents; | 158 HeapVector<Member<Event>> m_enqueuedEvents; |
158 | 159 |
159 Member<IDBDatabaseCallbacks> m_databaseCallbacks; | 160 Member<IDBDatabaseCallbacks> m_databaseCallbacks; |
160 }; | 161 }; |
161 | 162 |
162 } // namespace blink | 163 } // namespace blink |
163 | 164 |
164 #endif // IDBDatabase_h | 165 #endif // IDBDatabase_h |
OLD | NEW |