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

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBRequestLoader.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 IDBRequestLoader_h
6 #define IDBRequestLoader_h
7
8 #include "core/fileapi/FileReaderLoaderClient.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 FileReaderLoader;
18 class IDBRequestQueueItem;
19 class IDBRequest;
20 class IDBValue;
21
22 // Loads IndexedDB values that have been wrapped in Blobs by IDBValueWrapper.
23 //
24 // An IDBRequestLoader unwraps the result of a single IDBRequest. While most
25 // IndexedDB requests result in a single value, getAll() in IDBObjectStore and
jsbell 2017/05/15 23:37:38 Should we add a TODO to handle fetches of multiple
pwnall 2017/05/19 18:27:34 Done. I added it in the .cpp file. The loader API
26 // IDBIndex results in an array of values. In the interest of simplicity,
27 // IDBRequestLoader only knows how to unwrap an array of values, even though
28 // most of the time the array will consist of a single element. This design
29 // assumes that the overhead of creating and destroying a Vector is much smaller
30 // than the IPC overhead required to load the Blob data into the renderer.
31 class IDBRequestLoader : public FileReaderLoaderClient {
32 public:
33 // Creates a loader that will unwrap IDBValues received by a IDBRequest.
34 //
35 // result_values must be kept alive until the loader calls
36 // IDBRequestQueueItem::MarkReady().
37 IDBRequestLoader(IDBRequestQueueItem*,
38 Vector<RefPtr<IDBValue>>* result_values);
39
40 ~IDBRequestLoader() override;
41
42 static bool NeedsUnwrapping(IDBValue*);
jsbell 2017/05/15 23:37:38 If we drop the use of these methods then IDBReques
pwnall 2017/05/19 18:27:34 Ack. Also, the loader will grow in size and compl
43 static bool NeedUnwrapping(const Vector<RefPtr<IDBValue>>&);
44
45 // Start unwrapping values.
46 //
47 // When the unwrapping completes, the loader will call MarkReady() on the
48 // request queue item.
49 void Start();
50
51 // FileReaderLoaderClient implementaton.
52 void DidStartLoading() override;
53 void DidReceiveDataForClient(const char* data, unsigned data_length) override;
54 void DidFinishLoading() override;
55 void DidFail(FileError::ErrorCode) override;
56
57 private:
58 // Starts unwrapping the next wrapped IDBValue.
59 //
60 // If no more wrapped IDBValues are found, this calls the IDBRequest
61 // callbacks.
62 void StartNextValue();
63
64 void ReportSuccess();
65 void ReportError();
66
67 std::unique_ptr<FileReaderLoader> loader_;
68
69 // Transaction result queue item for the IDBRequest.
70 //
71 // The IDBRequestQueueItem owns this loader.
72 IDBRequestQueueItem* queue_item_;
73
74 // All the values that will be passed back to the IDBRequest.
75 Vector<RefPtr<IDBValue>>* const values_;
jsbell 2017/05/15 23:37:38 Comment on who owns this. (it's implied in the con
pwnall 2017/05/19 18:27:34 Done.
76
77 // Buffer used to unwrap an IDBValue.
78 Vector<char> wrapped_data_;
79
80 // The value being currently unwrapped.
81 Vector<RefPtr<IDBValue>>::iterator current_value_;
82 };
83
84 } // namespace blink
85
86 #endif // IDBRequestLoader_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698