Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBRequestQueueItem.h

Issue 2822453003: Wrap large IndexedDB values into Blobs before writing to LevelDB. (Closed)
Patch Set: Rebased. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef IDBRequestQueueItem_h
6 #define IDBRequestQueueItem_h
7
8 #include "platform/heap/Handle.h"
9 #include "platform/wtf/Allocator.h"
10 #include "platform/wtf/PassRefPtr.h"
11 #include "platform/wtf/RefPtr.h"
12 #include "platform/wtf/Vector.h"
13
14 #include <memory>
15
16 namespace blink {
17
18 class DOMException;
19 class IDBKey;
20 class IDBRequest;
21 class IDBRequestLoader;
22 class IDBValue;
23 class WebIDBCursor;
24
25 // Queues up a transaction's IDBRequest results for orderly delivery.
26 //
27 // The IndexedDB specification requires that the events corresponding to IDB
28 // request results fire in the order in which the requests were issued. The
29 // browser-side backend processes requests in order, but the Blink side may need
30 // to perform post-processing on the results (e.g. large value unwrapping).
31 // When a result needs post-processing, this queue captures all results received
32 // during the post-processing steps. The events for these results may only fire
33 // after the post-processed result's event is fired.
34 class IDBRequestQueueItem {
35 USING_FAST_MALLOC(IDBRequestQueueItem);
36
37 public:
38 IDBRequestQueueItem(IDBRequest*, DOMException*);
dmurph 2017/05/23 18:16:39 I'd love to remove IDBRequest from the class all t
pwnall 2017/05/25 13:27:11 This is not straightforward because some of the va
dmurph 2017/05/25 17:28:06 sgtm
39 IDBRequestQueueItem(IDBRequest*, int64_t);
40 IDBRequestQueueItem(IDBRequest*);
41 IDBRequestQueueItem(IDBRequest*, IDBKey*);
42 IDBRequestQueueItem(IDBRequest*, PassRefPtr<IDBValue>, bool attach_loader);
43 IDBRequestQueueItem(IDBRequest*,
44 const Vector<RefPtr<IDBValue>>&,
45 bool attach_loader);
46 IDBRequestQueueItem(IDBRequest*,
47 IDBKey*,
48 IDBKey* primary_key,
49 PassRefPtr<IDBValue>,
50 bool attach_loader);
51 IDBRequestQueueItem(IDBRequest*,
52 std::unique_ptr<WebIDBCursor>,
53 IDBKey*,
54 IDBKey* primary_key,
55 PassRefPtr<IDBValue>,
56 bool attach_loader);
57 ~IDBRequestQueueItem();
58
59 // False if this result still requires post-processing.
60 inline bool IsReady() { return ready_; }
61
62 // The request whose queued result is tracked by this item.
63 inline IDBRequest* Request() { return request_; }
64
65 // Starts post-processing the IDBRequest's result.
66 //
67 // This method must be called after the IDBRequestQueueItem is enqueued into
68 // the appropriate queue, because it is possible for the loading operation to
69 // complete synchronously, in which case IDBTransaction::OnResultReady() will
70 // be called with the (presumably) enqueued IDBRequest before this method
71 // returns.
72 void StartLoading();
73
74 // Stops post-processing the IDBRequest's result.
75 //
76 // This method may be called without an associated StartLoading().
77 void CancelLoading();
78
79 // Calls the correct EnqueueResponse overload on the associated request.
80 //
81 // This should only be called by the request's IDBTransaction.
82 void EnqueueResponse();
83
84 // Called by the associated IDBRequestLoader when result processing is done.
85 void OnResultLoadComplete();
86
87 // Called by the associated IDBRequestLoader when result processing fails.
88 void OnResultLoadComplete(DOMException* error);
89
90 private:
91 // The IDBRequest callback that will be called for this result.
92 enum ResponseType {
93 kCursorKeyPrimaryKeyValue,
94 kError,
95 kNumber,
96 kKey,
97 kKeyPrimaryKeyValue,
98 kValue,
99 kValueArray,
100 kVoid,
101 };
102
103 // The IDBRequest that will receive a callback for this result.
104 Persistent<IDBRequest> request_;
105
106 // The key argument to the IDBRequest callback.
107 //
108 // Only used if mode_ is kKeyPrimaryKeyValue.
109 Persistent<IDBKey> key_;
110
111 // The primary_key argument to the IDBRequest callback.
112 //
113 // Only used if mode_ is kKeyPrimaryKeyValue.
114 Persistent<IDBKey> primary_key_;
115
116 // The error argument to the IDBRequest callback.
117 //
118 // Only used if the mode_ is kError.
119 Persistent<DOMException> error_;
120
121 // All the values that will be passed back to the IDBRequest.
122 Vector<RefPtr<IDBValue>> values_;
123
124 // The cursor argument to the IDBRequest callback.
125 std::unique_ptr<WebIDBCursor> cursor_;
126
127 // Performs post-processing on this result.
128 //
129 // nullptr for results that do not require post-processing and for results
130 // whose post-processing has completed.
131 std::unique_ptr<IDBRequestLoader> loader_;
132
133 // The integer value argument to the IDBRequest callback.
134 int64_t int64_value_;
135
136 // Identifies the IDBRequest::EnqueueResponse() overload that will be called.
137 ResponseType response_type_;
138
139 // False if this result still requires post-processing.
140 bool ready_;
141
142 #if DCHECK_IS_ON()
143 bool callback_fired_ = false;
144 #endif // DCHECK_IS_ON()
145 };
146
147 using IDBRequestQueue = Deque<std::unique_ptr<IDBRequestQueueItem>>;
148
149 } // namespace blink
150
151 #endif // IDBRequestQueueItem_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698