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 11 matching lines...) Expand all Loading... | |
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
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 <memory> | |
33 | |
32 #include "bindings/core/v8/ActiveScriptWrappable.h" | 34 #include "bindings/core/v8/ActiveScriptWrappable.h" |
33 #include "bindings/core/v8/ScriptState.h" | 35 #include "bindings/core/v8/ScriptState.h" |
34 #include "bindings/core/v8/ScriptValue.h" | 36 #include "bindings/core/v8/ScriptValue.h" |
35 #include "core/dom/DOMStringList.h" | 37 #include "core/dom/DOMStringList.h" |
36 #include "core/dom/SuspendableObject.h" | 38 #include "core/dom/SuspendableObject.h" |
37 #include "core/events/EventListener.h" | 39 #include "core/events/EventListener.h" |
38 #include "core/events/EventTarget.h" | 40 #include "core/events/EventTarget.h" |
39 #include "modules/EventModules.h" | 41 #include "modules/EventModules.h" |
40 #include "modules/ModulesExport.h" | 42 #include "modules/ModulesExport.h" |
41 #include "modules/indexeddb/IDBAny.h" | 43 #include "modules/indexeddb/IDBAny.h" |
42 #include "modules/indexeddb/IDBTransaction.h" | 44 #include "modules/indexeddb/IDBTransaction.h" |
43 #include "modules/indexeddb/IndexedDB.h" | 45 #include "modules/indexeddb/IndexedDB.h" |
44 #include "platform/blob/BlobData.h" | 46 #include "platform/blob/BlobData.h" |
45 #include "platform/heap/Handle.h" | 47 #include "platform/heap/Handle.h" |
48 #include "platform/wtf/HashMap.h" | |
46 #include "public/platform/WebBlobInfo.h" | 49 #include "public/platform/WebBlobInfo.h" |
47 #include "public/platform/modules/indexeddb/WebIDBCursor.h" | 50 #include "public/platform/modules/indexeddb/WebIDBCursor.h" |
48 #include "public/platform/modules/indexeddb/WebIDBTypes.h" | 51 #include "public/platform/modules/indexeddb/WebIDBTypes.h" |
49 #include <memory> | |
50 | 52 |
51 namespace blink { | 53 namespace blink { |
52 | 54 |
53 class DOMException; | 55 class DOMException; |
54 class ExceptionState; | 56 class ExceptionState; |
55 class IDBCursor; | 57 class IDBCursor; |
56 struct IDBDatabaseMetadata; | 58 struct IDBDatabaseMetadata; |
57 class IDBValue; | 59 class IDBValue; |
58 | 60 |
59 class MODULES_EXPORT IDBRequest : public EventTargetWithInlineData, | 61 class MODULES_EXPORT IDBRequest : public EventTargetWithInlineData, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 ExecutionContext* GetExecutionContext() const final; | 136 ExecutionContext* GetExecutionContext() const final; |
135 void UncaughtExceptionInEventHandler() final; | 137 void UncaughtExceptionInEventHandler() final; |
136 | 138 |
137 // Called by a version change transaction that has finished to set this | 139 // Called by a version change transaction that has finished to set this |
138 // request back from DONE (following "upgradeneeded") back to PENDING (for | 140 // request back from DONE (following "upgradeneeded") back to PENDING (for |
139 // the upcoming "success" or "error"). | 141 // the upcoming "success" or "error"). |
140 void TransactionDidFinishAndDispatch(); | 142 void TransactionDidFinishAndDispatch(); |
141 | 143 |
142 IDBCursor* GetResultCursor() const; | 144 IDBCursor* GetResultCursor() const; |
143 | 145 |
146 void StorePutOperationBlobs( | |
michaeln
2017/04/25 23:37:00
nit: consider naming the StoreXXX and ClearXXX met
dmurph
2017/04/27 22:04:12
Done.
| |
147 HashMap<String, RefPtr<BlobDataHandle>> blob_handles) { | |
148 transit_blob_handles_ = std::move(blob_handles); | |
149 } | |
150 | |
144 protected: | 151 protected: |
145 IDBRequest(ScriptState*, IDBAny* source, IDBTransaction*); | 152 IDBRequest(ScriptState*, IDBAny* source, IDBTransaction*); |
146 void EnqueueEvent(Event*); | 153 void EnqueueEvent(Event*); |
147 void DequeueEvent(Event*); | 154 void DequeueEvent(Event*); |
148 virtual bool ShouldEnqueueEvent() const; | 155 virtual bool ShouldEnqueueEvent() const; |
149 void OnSuccessInternal(IDBAny*); | 156 void OnSuccessInternal(IDBAny*); |
150 void SetResult(IDBAny*); | 157 void SetResult(IDBAny*); |
151 | 158 |
152 // EventTarget | 159 // EventTarget |
153 DispatchEventResult DispatchEventInternal(Event*) override; | 160 DispatchEventResult DispatchEventInternal(Event*) override; |
154 | 161 |
155 Member<IDBTransaction> transaction_; | 162 Member<IDBTransaction> transaction_; |
156 ReadyState ready_state_ = PENDING; | 163 ReadyState ready_state_ = PENDING; |
157 bool request_aborted_ = false; // May be aborted by transaction then receive | 164 bool request_aborted_ = false; // May be aborted by transaction then receive |
158 // async onsuccess; ignore vs. assert. | 165 // async onsuccess; ignore vs. assert. |
159 // Maintain the isolate so that all externally allocated memory can be | 166 // Maintain the isolate so that all externally allocated memory can be |
160 // registered against it. | 167 // registered against it. |
161 v8::Isolate* isolate_; | 168 v8::Isolate* isolate_; |
162 | 169 |
163 private: | 170 private: |
164 void SetResultCursor(IDBCursor*, | 171 void SetResultCursor(IDBCursor*, |
165 IDBKey*, | 172 IDBKey*, |
166 IDBKey* primary_key, | 173 IDBKey* primary_key, |
167 PassRefPtr<IDBValue>); | 174 PassRefPtr<IDBValue>); |
168 void AckReceivedBlobs(const IDBValue*); | 175 void AckReceivedBlobs(const IDBValue*); |
169 void AckReceivedBlobs(const Vector<RefPtr<IDBValue>>&); | 176 void AckReceivedBlobs(const Vector<RefPtr<IDBValue>>&); |
170 | 177 |
178 void ClearTransitBlobHandles() { transit_blob_handles_.clear(); } | |
179 | |
171 Member<IDBAny> source_; | 180 Member<IDBAny> source_; |
172 Member<IDBAny> result_; | 181 Member<IDBAny> result_; |
173 Member<DOMException> error_; | 182 Member<DOMException> error_; |
174 | 183 |
175 bool has_pending_activity_ = true; | 184 bool has_pending_activity_ = true; |
176 HeapVector<Member<Event>> enqueued_events_; | 185 HeapVector<Member<Event>> enqueued_events_; |
177 | 186 |
178 // Only used if the result type will be a cursor. | 187 // Only used if the result type will be a cursor. |
179 IndexedDB::CursorType cursor_type_ = IndexedDB::kCursorKeyAndValue; | 188 IndexedDB::CursorType cursor_type_ = IndexedDB::kCursorKeyAndValue; |
180 WebIDBCursorDirection cursor_direction_ = kWebIDBCursorDirectionNext; | 189 WebIDBCursorDirection cursor_direction_ = kWebIDBCursorDirectionNext; |
181 // When a cursor is continued/advanced, |result_| is cleared and | 190 // When a cursor is continued/advanced, |result_| is cleared and |
182 // |pendingCursor_| holds it. | 191 // |pendingCursor_| holds it. |
183 Member<IDBCursor> pending_cursor_; | 192 Member<IDBCursor> pending_cursor_; |
184 // New state is not applied to the cursor object until the event is | 193 // New state is not applied to the cursor object until the event is |
185 // dispatched. | 194 // dispatched. |
186 Member<IDBKey> cursor_key_; | 195 Member<IDBKey> cursor_key_; |
187 Member<IDBKey> cursor_primary_key_; | 196 Member<IDBKey> cursor_primary_key_; |
188 RefPtr<IDBValue> cursor_value_; | 197 RefPtr<IDBValue> cursor_value_; |
189 | 198 |
199 HashMap<String, RefPtr<BlobDataHandle>> transit_blob_handles_; | |
200 | |
190 bool did_fire_upgrade_needed_event_ = false; | 201 bool did_fire_upgrade_needed_event_ = false; |
191 bool prevent_propagation_ = false; | 202 bool prevent_propagation_ = false; |
192 bool result_dirty_ = true; | 203 bool result_dirty_ = true; |
193 | 204 |
194 // Transactions should be aborted after event dispatch if an exception was | 205 // Transactions should be aborted after event dispatch if an exception was |
195 // not caught. This is cleared before dispatch, set by a call to | 206 // not caught. This is cleared before dispatch, set by a call to |
196 // UncaughtExceptionInEventHandler() during dispatch, and checked afterwards | 207 // UncaughtExceptionInEventHandler() during dispatch, and checked afterwards |
197 // to abort if necessary. | 208 // to abort if necessary. |
198 bool did_throw_in_event_handler_ = false; | 209 bool did_throw_in_event_handler_ = false; |
199 | 210 |
200 // Pointer back to the WebIDBCallbacks that holds a persistent reference to | 211 // Pointer back to the WebIDBCallbacks that holds a persistent reference to |
201 // this object. | 212 // this object. |
202 WebIDBCallbacks* web_callbacks_ = nullptr; | 213 WebIDBCallbacks* web_callbacks_ = nullptr; |
203 }; | 214 }; |
204 | 215 |
205 } // namespace blink | 216 } // namespace blink |
206 | 217 |
207 #endif // IDBRequest_h | 218 #endif // IDBRequest_h |
OLD | NEW |