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

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: WIP: Getting IDBRequestTest.EventsAfterStopping to pass. 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/PassRefPtr.h"
10 #include "platform/wtf/RefPtr.h"
11 #include "platform/wtf/Vector.h"
12
13 #include <memory>
14
15 namespace blink {
16
17 class DOMException;
18 class IDBKey;
19 class IDBRequest;
20 class IDBRequestLoader;
21 class IDBValue;
22 class WebIDBCursor;
23
24 // Queues up a transaction's IDBRequest results for orderly delivery.
25 //
26 // The IndexedDB specification requires that the events corresponding to IDB
27 // request results fire in the order in which the requests were issued. The
28 // browser-side backend processes requests in order, but the Blink side may need
29 // to perform post-processing on the results (e.g. large value unwrapping).
30 // When a result needs post-processing, this queue captures all results received
31 // during the post-processing steps. The events for these results may only fire
32 // after the post-processed result's event is fired.
33 class IDBRequestQueueItem {
34 public:
35 IDBRequestQueueItem(IDBRequest*, DOMException*);
36 IDBRequestQueueItem(IDBRequest*, int64_t);
37 IDBRequestQueueItem(IDBRequest*);
38 IDBRequestQueueItem(IDBRequest*, IDBKey*);
39 IDBRequestQueueItem(IDBRequest*, PassRefPtr<IDBValue>, bool attach_loader);
40 IDBRequestQueueItem(IDBRequest*,
41 const Vector<RefPtr<IDBValue>>&,
42 bool attach_loader);
43 IDBRequestQueueItem(IDBRequest*,
44 IDBKey*,
45 IDBKey* primary_key,
46 PassRefPtr<IDBValue>,
47 bool attach_loader);
48 IDBRequestQueueItem(IDBRequest*,
49 std::unique_ptr<WebIDBCursor> backend,
50 IDBKey*,
51 IDBKey* primary_key,
52 PassRefPtr<IDBValue>,
53 bool attach_loader);
54 ~IDBRequestQueueItem();
55
56 // False if this result still requires post-processing.
57 inline bool IsReady() { return ready_; }
58
59 // The request whose queued result is tracked by this item.
60 inline IDBRequest* Request() { return request_; }
61
62 // Starts post-processing the IDBRequest's result.
63 //
64 // This method must be called after the IDBRequestQueueItem is enqueued into
65 // the appropriate queue, because it is possible for the loading operation to
66 // complete synchronously, in which case IDBTransaction::OnResultReady() will
67 // be called with the (presumably) enqueued IDBRequest before this method
68 // returns.
69 void StartLoading();
70
71 // Calls the correct overload of OnSuccess/OnError on the associated request.
72 //
73 // This should only be called by the request's IDBTransaction.
74 void FireCallback();
jsbell 2017/05/15 23:37:38 Nit about naming: 'Fire' has a specific DOM meanin
pwnall 2017/05/19 18:27:35 Done. Renamed to EnqueueResponse(), to match the m
75
76 // Marks the result as having being post-processed.
77 //
78 // This method should only be called by the associated IDBRequestLoader.
79 void MarkReady();
80 // Called when an error occurs during result post-processing.
81 //
82 // This method should only be called by the associated IDBRequestLoader.
83 void MarkReady(DOMException* error);
84
85 private:
86 // The IDBRequest callback that will be called for this result.
87 enum Mode {
jsbell 2017/05/15 23:37:38 Since 'mode' is a spec term/IDL enum (for transact
pwnall 2017/05/19 18:27:35 Done.
88 kBackendKeyPrimaryKeyValue,
jsbell 2017/05/15 23:37:38 I'd call this kCursorKeyPrimaryKeyValue
pwnall 2017/05/19 18:27:35 Done.
89 kError,
90 kInt64Value,
jsbell 2017/05/15 23:37:38 kNumber ?
pwnall 2017/05/19 18:27:34 Done.
91 kKey,
92 kKeyPrimaryKeyValue,
93 kNoArguments,
jsbell 2017/05/15 23:37:38 kVoid ?
pwnall 2017/05/19 18:27:34 Done.
94 kValue,
95 kValueArray,
96 };
97
98 // The IDBRequest that will receive a callback for this result.
99 Persistent<IDBRequest> request_;
100
101 // The key argument to the IDBRequest callback.
102 //
103 // Only used if mode_ is kKeyPrimaryKeyValue.
104 Persistent<IDBKey> key_;
105
106 // The primary_key argument to the IDBRequest callback.
107 //
108 // Only used if mode_ is kKeyPrimaryKeyValue.
109 Persistent<IDBKey> primary_key_;
110
111 // The error argument to the IDBRequest callback.
112 //
113 // Only used if the mode_ is kError.
114 Persistent<DOMException> error_;
115
116 // All the values that will be passed back to the IDBRequest.
117 Vector<RefPtr<IDBValue>> values_;
118
119 // The backend argument to the IDBRequest callback.
120 std::unique_ptr<WebIDBCursor> backend_;
jsbell 2017/05/15 23:37:38 'cursor' instead of 'backend' here?
pwnall 2017/05/19 18:27:35 Done.
121
122 // Performs post-processing on this result.
123 //
124 // nullptr for results that do not require post-processing and for results
125 // whose post-processing has completed.
126 std::unique_ptr<IDBRequestLoader> loader_;
127
128 // The integer value argument to the IDBRequest callback.
129 int64_t int64_value_;
130
131 // The IDBRequest callback that will be called for this result.
132 Mode mode_;
133
134 // False if this result still requires post-processing.
135 bool ready_;
136
137 #if DCHECK_IS_ON()
138 bool callback_fired_ = false;
139 #endif // DCHECK_IS_ON()
140 };
141
142 using IDBRequestQueue = Deque<std::unique_ptr<IDBRequestQueueItem>>;
143
144 } // namespace blink
145
146 #endif // IDBRequestQueueItem_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698