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

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: Fixed compilation errors on Windows and no-DCHECKs. 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/heap/Handle.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 FileReaderLoader;
19 class IDBRequestQueueItem;
20 class IDBRequest;
21 class IDBValue;
22
23 // Loads IndexedDB values that have been wrapped in Blobs by IDBValueWrapper.
24 class IDBRequestLoader : public GarbageCollectedFinalized<IDBRequestLoader>,
25 public FileReaderLoaderClient {
26 public:
27 // Creates a loader that will unwrap IDBValues received by a IDBRequest.
28 //
29 // result_values must be kept alive until the loader calls
30 // IDBRequestQueueItem::MarkReady().
31 IDBRequestLoader(IDBRequestQueueItem*,
32 Vector<RefPtr<IDBValue>>* result_values);
33
34 ~IDBRequestLoader() override;
35
36 static bool NeedsUnwrapping(IDBValue*);
37 static bool NeedUnwrapping(const Vector<RefPtr<IDBValue>>&);
38
39 // Start unwrapping values.
40 //
41 // When the unwrapping completes, the loader will call MarkReady() on the
42 // request queue item.
43 void Start();
44
45 // FileReaderLoaderClient implementaton.
46 void DidStartLoading() override;
47 void DidReceiveDataForClient(const char* data, unsigned data_length) override;
48 void DidFinishLoading() override;
49 void DidFail(FileError::ErrorCode) override;
50
51 DEFINE_INLINE_TRACE() { visitor->Trace(queue_item_); }
52
53 private:
54 // Starts unwrapping the next wrapped IDBValue.
55 //
56 // If no more wrapped IDBValues are found, this calls the IDBRequest
57 // callbacks.
58 void StartNextValue();
59
60 void ReportSuccess();
61 void ReportError();
62
63 std::unique_ptr<FileReaderLoader> loader_;
64
65 // Transaction result queue item for the IDBRequest.
66 Member<IDBRequestQueueItem> queue_item_;
67
68 // All the values that will be passed back to the IDBRequest.
69 Vector<RefPtr<IDBValue>>* const values_;
70
71 // Buffer used to unwrap an IDBValue.
72 Vector<char> wrapped_data_;
73
74 // The value being currently unwrapped.
75 Vector<RefPtr<IDBValue>>::iterator current_value_;
76 };
77
78 } // namespace blink
79
80 #endif // IDBRequestLoader_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698