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 14 matching lines...) Expand all Loading... |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 | 28 |
29 #ifndef IDBRequest_h | 29 #ifndef IDBRequest_h |
30 #define IDBRequest_h | 30 #define IDBRequest_h |
31 | 31 |
32 #include "bindings/core/v8/ScriptState.h" | 32 #include "bindings/core/v8/ScriptState.h" |
33 #include "bindings/core/v8/ScriptValue.h" | 33 #include "bindings/core/v8/ScriptValue.h" |
34 #include "core/dom/ActiveDOMObject.h" | 34 #include "core/dom/ActiveDOMObject.h" |
35 #include "core/dom/DOMError.h" | |
36 #include "core/dom/DOMStringList.h" | 35 #include "core/dom/DOMStringList.h" |
37 #include "core/events/EventListener.h" | 36 #include "core/events/EventListener.h" |
38 #include "core/events/EventTarget.h" | 37 #include "core/events/EventTarget.h" |
39 #include "modules/EventModules.h" | 38 #include "modules/EventModules.h" |
40 #include "modules/ModulesExport.h" | 39 #include "modules/ModulesExport.h" |
41 #include "modules/indexeddb/IDBAny.h" | 40 #include "modules/indexeddb/IDBAny.h" |
42 #include "modules/indexeddb/IDBTransaction.h" | 41 #include "modules/indexeddb/IDBTransaction.h" |
43 #include "modules/indexeddb/IndexedDB.h" | 42 #include "modules/indexeddb/IndexedDB.h" |
44 #include "platform/blob/BlobData.h" | 43 #include "platform/blob/BlobData.h" |
45 #include "platform/heap/Handle.h" | 44 #include "platform/heap/Handle.h" |
46 #include "public/platform/WebBlobInfo.h" | 45 #include "public/platform/WebBlobInfo.h" |
47 #include "public/platform/modules/indexeddb/WebIDBCursor.h" | 46 #include "public/platform/modules/indexeddb/WebIDBCursor.h" |
48 #include "public/platform/modules/indexeddb/WebIDBTypes.h" | 47 #include "public/platform/modules/indexeddb/WebIDBTypes.h" |
49 | 48 |
50 namespace blink { | 49 namespace blink { |
51 | 50 |
| 51 class DOMException; |
52 class ExceptionState; | 52 class ExceptionState; |
53 class IDBCursor; | 53 class IDBCursor; |
54 struct IDBDatabaseMetadata; | 54 struct IDBDatabaseMetadata; |
55 class IDBValue; | 55 class IDBValue; |
56 | 56 |
57 class MODULES_EXPORT IDBRequest | 57 class MODULES_EXPORT IDBRequest |
58 : public RefCountedGarbageCollectedEventTargetWithInlineData<IDBRequest> | 58 : public RefCountedGarbageCollectedEventTargetWithInlineData<IDBRequest> |
59 , public ActiveDOMObject { | 59 , public ActiveDOMObject { |
60 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(IDBRequest); | 60 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(IDBRequest); |
61 DEFINE_WRAPPERTYPEINFO(); | 61 DEFINE_WRAPPERTYPEINFO(); |
62 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(IDBRequest); | 62 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(IDBRequest); |
63 public: | 63 public: |
64 static IDBRequest* create(ScriptState*, IDBAny* source, IDBTransaction*); | 64 static IDBRequest* create(ScriptState*, IDBAny* source, IDBTransaction*); |
65 ~IDBRequest() override; | 65 ~IDBRequest() override; |
66 DECLARE_VIRTUAL_TRACE(); | 66 DECLARE_VIRTUAL_TRACE(); |
67 | 67 |
68 ScriptState* scriptState() { return m_scriptState.get(); } | 68 ScriptState* scriptState() { return m_scriptState.get(); } |
69 ScriptValue result(ExceptionState&); | 69 ScriptValue result(ExceptionState&); |
70 DOMError* error(ExceptionState&) const; | 70 DOMException* error(ExceptionState&) const; |
71 ScriptValue source() const; | 71 ScriptValue source() const; |
72 IDBTransaction* transaction() const { return m_transaction.get(); } | 72 IDBTransaction* transaction() const { return m_transaction.get(); } |
73 | 73 |
74 bool isResultDirty() const { return m_resultDirty; } | 74 bool isResultDirty() const { return m_resultDirty; } |
75 IDBAny* resultAsAny() const { return m_result; } | 75 IDBAny* resultAsAny() const { return m_result; } |
76 | 76 |
77 // Requests made during index population are implementation details and so | 77 // Requests made during index population are implementation details and so |
78 // events should not be visible to script. | 78 // events should not be visible to script. |
79 void preventPropagation() { m_preventPropagation = true; } | 79 void preventPropagation() { m_preventPropagation = true; } |
80 | 80 |
81 // Defined in the IDL | 81 // Defined in the IDL |
82 enum ReadyState { | 82 enum ReadyState { |
83 PENDING = 1, | 83 PENDING = 1, |
84 DONE = 2, | 84 DONE = 2, |
85 EarlyDeath = 3 | 85 EarlyDeath = 3 |
86 }; | 86 }; |
87 | 87 |
88 const String& readyState() const; | 88 const String& readyState() const; |
89 | 89 |
90 DEFINE_ATTRIBUTE_EVENT_LISTENER(success); | 90 DEFINE_ATTRIBUTE_EVENT_LISTENER(success); |
91 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 91 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
92 | 92 |
93 void setCursorDetails(IndexedDB::CursorType, WebIDBCursorDirection); | 93 void setCursorDetails(IndexedDB::CursorType, WebIDBCursorDirection); |
94 void setPendingCursor(IDBCursor*); | 94 void setPendingCursor(IDBCursor*); |
95 void abort(); | 95 void abort(); |
96 | 96 |
97 virtual void onError(DOMError*); | 97 virtual void onError(DOMException*); |
98 virtual void onSuccess(const Vector<String>&); | 98 virtual void onSuccess(const Vector<String>&); |
99 virtual void onSuccess(PassOwnPtr<WebIDBCursor>, IDBKey*, IDBKey* primaryKey
, PassRefPtr<IDBValue>); | 99 virtual void onSuccess(PassOwnPtr<WebIDBCursor>, IDBKey*, IDBKey* primaryKey
, PassRefPtr<IDBValue>); |
100 virtual void onSuccess(IDBKey*); | 100 virtual void onSuccess(IDBKey*); |
101 virtual void onSuccess(PassRefPtr<IDBValue>); | 101 virtual void onSuccess(PassRefPtr<IDBValue>); |
102 virtual void onSuccess(const Vector<RefPtr<IDBValue>>&); | 102 virtual void onSuccess(const Vector<RefPtr<IDBValue>>&); |
103 virtual void onSuccess(int64_t); | 103 virtual void onSuccess(int64_t); |
104 virtual void onSuccess(); | 104 virtual void onSuccess(); |
105 virtual void onSuccess(IDBKey*, IDBKey* primaryKey, PassRefPtr<IDBValue>); | 105 virtual void onSuccess(IDBKey*, IDBKey* primaryKey, PassRefPtr<IDBValue>); |
106 | 106 |
107 // Only IDBOpenDBRequest instances should receive these: | 107 // Only IDBOpenDBRequest instances should receive these: |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 bool m_requestAborted = false; // May be aborted by transaction then receive
async onsuccess; ignore vs. assert. | 142 bool m_requestAborted = false; // May be aborted by transaction then receive
async onsuccess; ignore vs. assert. |
143 | 143 |
144 private: | 144 private: |
145 void setResultCursor(IDBCursor*, IDBKey*, IDBKey* primaryKey, PassRefPtr<IDB
Value>); | 145 void setResultCursor(IDBCursor*, IDBKey*, IDBKey* primaryKey, PassRefPtr<IDB
Value>); |
146 void ackReceivedBlobs(const IDBValue*); | 146 void ackReceivedBlobs(const IDBValue*); |
147 void ackReceivedBlobs(const Vector<RefPtr<IDBValue>>&); | 147 void ackReceivedBlobs(const Vector<RefPtr<IDBValue>>&); |
148 | 148 |
149 RefPtr<ScriptState> m_scriptState; | 149 RefPtr<ScriptState> m_scriptState; |
150 Member<IDBAny> m_source; | 150 Member<IDBAny> m_source; |
151 Member<IDBAny> m_result; | 151 Member<IDBAny> m_result; |
152 Member<DOMError> m_error; | 152 Member<DOMException> m_error; |
153 | 153 |
154 bool m_hasPendingActivity = true; | 154 bool m_hasPendingActivity = true; |
155 WillBeHeapVector<RefPtrWillBeMember<Event>> m_enqueuedEvents; | 155 WillBeHeapVector<RefPtrWillBeMember<Event>> m_enqueuedEvents; |
156 | 156 |
157 // Only used if the result type will be a cursor. | 157 // Only used if the result type will be a cursor. |
158 IndexedDB::CursorType m_cursorType = IndexedDB::CursorKeyAndValue; | 158 IndexedDB::CursorType m_cursorType = IndexedDB::CursorKeyAndValue; |
159 WebIDBCursorDirection m_cursorDirection = WebIDBCursorDirectionNext; | 159 WebIDBCursorDirection m_cursorDirection = WebIDBCursorDirectionNext; |
160 // When a cursor is continued/advanced, m_result is cleared and m_pendingCur
sor holds it. | 160 // When a cursor is continued/advanced, m_result is cleared and m_pendingCur
sor holds it. |
161 Member<IDBCursor> m_pendingCursor; | 161 Member<IDBCursor> m_pendingCursor; |
162 // New state is not applied to the cursor object until the event is dispatch
ed. | 162 // New state is not applied to the cursor object until the event is dispatch
ed. |
163 Member<IDBKey> m_cursorKey; | 163 Member<IDBKey> m_cursorKey; |
164 Member<IDBKey> m_cursorPrimaryKey; | 164 Member<IDBKey> m_cursorPrimaryKey; |
165 RefPtr<IDBValue> m_cursorValue; | 165 RefPtr<IDBValue> m_cursorValue; |
166 | 166 |
167 bool m_didFireUpgradeNeededEvent = false; | 167 bool m_didFireUpgradeNeededEvent = false; |
168 bool m_preventPropagation = false; | 168 bool m_preventPropagation = false; |
169 bool m_resultDirty = true; | 169 bool m_resultDirty = true; |
170 }; | 170 }; |
171 | 171 |
172 } // namespace blink | 172 } // namespace blink |
173 | 173 |
174 #endif // IDBRequest_h | 174 #endif // IDBRequest_h |
OLD | NEW |