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 13 matching lines...) Expand all Loading... |
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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/ContextLifecycleObserver.h" |
35 #include "core/dom/DOMStringList.h" | 35 #include "core/dom/DOMStringList.h" |
36 #include "core/events/EventListener.h" | 36 #include "core/events/EventListener.h" |
37 #include "core/events/EventTarget.h" | 37 #include "core/events/EventTarget.h" |
38 #include "modules/EventModules.h" | 38 #include "modules/EventModules.h" |
39 #include "modules/ModulesExport.h" | 39 #include "modules/ModulesExport.h" |
40 #include "modules/indexeddb/IDBAny.h" | 40 #include "modules/indexeddb/IDBAny.h" |
41 #include "modules/indexeddb/IDBTransaction.h" | 41 #include "modules/indexeddb/IDBTransaction.h" |
42 #include "modules/indexeddb/IndexedDB.h" | 42 #include "modules/indexeddb/IndexedDB.h" |
43 #include "platform/blob/BlobData.h" | 43 #include "platform/blob/BlobData.h" |
44 #include "platform/heap/Handle.h" | 44 #include "platform/heap/Handle.h" |
45 #include "public/platform/WebBlobInfo.h" | 45 #include "public/platform/WebBlobInfo.h" |
46 #include "public/platform/modules/indexeddb/WebIDBCursor.h" | 46 #include "public/platform/modules/indexeddb/WebIDBCursor.h" |
47 #include "public/platform/modules/indexeddb/WebIDBTypes.h" | 47 #include "public/platform/modules/indexeddb/WebIDBTypes.h" |
48 | 48 |
49 namespace blink { | 49 namespace blink { |
50 | 50 |
51 class DOMException; | 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 ContextLifecycleObserver { |
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&); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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: |
108 virtual void onBlocked(int64_t oldVersion) { ASSERT_NOT_REACHED(); } | 108 virtual void onBlocked(int64_t oldVersion) { ASSERT_NOT_REACHED(); } |
109 virtual void onUpgradeNeeded(int64_t oldVersion, PassOwnPtr<WebIDBDatabase>,
const IDBDatabaseMetadata&, WebIDBDataLoss, String dataLossMessage) { ASSERT_NO
T_REACHED(); } | 109 virtual void onUpgradeNeeded(int64_t oldVersion, PassOwnPtr<WebIDBDatabase>,
const IDBDatabaseMetadata&, WebIDBDataLoss, String dataLossMessage) { ASSERT_NO
T_REACHED(); } |
110 virtual void onSuccess(PassOwnPtr<WebIDBDatabase>, const IDBDatabaseMetadata
&) { ASSERT_NOT_REACHED(); } | 110 virtual void onSuccess(PassOwnPtr<WebIDBDatabase>, const IDBDatabaseMetadata
&) { ASSERT_NOT_REACHED(); } |
111 | 111 |
112 // ActiveDOMObject | |
113 bool hasPendingActivity() const final; | 112 bool hasPendingActivity() const final; |
114 void stop() final; | 113 void contextDestroyed() final; |
115 | 114 |
116 // EventTarget | 115 // EventTarget |
117 const AtomicString& interfaceName() const override; | 116 const AtomicString& interfaceName() const override; |
118 ExecutionContext* executionContext() const final; | 117 ExecutionContext* executionContext() const final; |
119 void uncaughtExceptionInEventHandler() final; | 118 void uncaughtExceptionInEventHandler() final; |
120 | 119 |
121 // Called by a version change transaction that has finished to set this | 120 // Called by a version change transaction that has finished to set this |
122 // request back from DONE (following "upgradeneeded") back to PENDING (for | 121 // request back from DONE (following "upgradeneeded") back to PENDING (for |
123 // the upcoming "success" or "error"). | 122 // the upcoming "success" or "error"). |
124 void transactionDidFinishAndDispatch(); | 123 void transactionDidFinishAndDispatch(); |
125 | 124 |
126 IDBCursor* getResultCursor() const; | 125 IDBCursor* getResultCursor() const; |
127 | 126 |
128 protected: | 127 protected: |
129 IDBRequest(ScriptState*, IDBAny* source, IDBTransaction*); | 128 IDBRequest(ScriptState*, IDBAny* source, IDBTransaction*); |
130 void enqueueEvent(PassRefPtrWillBeRawPtr<Event>); | 129 void enqueueEvent(PassRefPtrWillBeRawPtr<Event>); |
131 void dequeueEvent(Event*); | 130 void dequeueEvent(Event*); |
132 virtual bool shouldEnqueueEvent() const; | 131 virtual bool shouldEnqueueEvent() const; |
133 void onSuccessInternal(IDBAny*); | 132 void onSuccessInternal(IDBAny*); |
134 void setResult(IDBAny*); | 133 void setResult(IDBAny*); |
135 | 134 |
136 // EventTarget | 135 // EventTarget |
137 DispatchEventResult dispatchEventInternal(PassRefPtrWillBeRawPtr<Event>) ove
rride; | 136 DispatchEventResult dispatchEventInternal(PassRefPtrWillBeRawPtr<Event>) ove
rride; |
138 | 137 |
139 bool m_contextStopped = false; | |
140 Member<IDBTransaction> m_transaction; | 138 Member<IDBTransaction> m_transaction; |
141 ReadyState m_readyState = PENDING; | 139 ReadyState m_readyState = PENDING; |
142 bool m_requestAborted = false; // May be aborted by transaction then receive
async onsuccess; ignore vs. assert. | 140 bool m_requestAborted = false; // May be aborted by transaction then receive
async onsuccess; ignore vs. assert. |
143 | 141 |
144 private: | 142 private: |
145 void setResultCursor(IDBCursor*, IDBKey*, IDBKey* primaryKey, PassRefPtr<IDB
Value>); | 143 void setResultCursor(IDBCursor*, IDBKey*, IDBKey* primaryKey, PassRefPtr<IDB
Value>); |
146 void ackReceivedBlobs(const IDBValue*); | 144 void ackReceivedBlobs(const IDBValue*); |
147 void ackReceivedBlobs(const Vector<RefPtr<IDBValue>>&); | 145 void ackReceivedBlobs(const Vector<RefPtr<IDBValue>>&); |
148 | 146 |
149 RefPtr<ScriptState> m_scriptState; | 147 RefPtr<ScriptState> m_scriptState; |
(...skipping 15 matching lines...) Expand all Loading... |
165 RefPtr<IDBValue> m_cursorValue; | 163 RefPtr<IDBValue> m_cursorValue; |
166 | 164 |
167 bool m_didFireUpgradeNeededEvent = false; | 165 bool m_didFireUpgradeNeededEvent = false; |
168 bool m_preventPropagation = false; | 166 bool m_preventPropagation = false; |
169 bool m_resultDirty = true; | 167 bool m_resultDirty = true; |
170 }; | 168 }; |
171 | 169 |
172 } // namespace blink | 170 } // namespace blink |
173 | 171 |
174 #endif // IDBRequest_h | 172 #endif // IDBRequest_h |
OLD | NEW |