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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/indexeddb/IDBRequestLoader.h
diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBRequestLoader.h b/third_party/WebKit/Source/modules/indexeddb/IDBRequestLoader.h
new file mode 100644
index 0000000000000000000000000000000000000000..1ae68c1c4d55181f343c400b36539b1d2dbb38fb
--- /dev/null
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBRequestLoader.h
@@ -0,0 +1,80 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IDBRequestLoader_h
+#define IDBRequestLoader_h
+
+#include "core/fileapi/FileReaderLoaderClient.h"
+#include "platform/heap/Handle.h"
+#include "platform/wtf/PassRefPtr.h"
+#include "platform/wtf/RefPtr.h"
+#include "platform/wtf/Vector.h"
+
+#include <memory>
+
+namespace blink {
+
+class FileReaderLoader;
+class IDBRequestQueueItem;
+class IDBRequest;
+class IDBValue;
+
+// Loads IndexedDB values that have been wrapped in Blobs by IDBValueWrapper.
+class IDBRequestLoader : public GarbageCollectedFinalized<IDBRequestLoader>,
+ public FileReaderLoaderClient {
+ public:
+ // Creates a loader that will unwrap IDBValues received by a IDBRequest.
+ //
+ // result_values must be kept alive until the loader calls
+ // IDBRequestQueueItem::MarkReady().
+ IDBRequestLoader(IDBRequestQueueItem*,
+ Vector<RefPtr<IDBValue>>* result_values);
+
+ ~IDBRequestLoader() override;
+
+ static bool NeedsUnwrapping(IDBValue*);
+ static bool NeedUnwrapping(const Vector<RefPtr<IDBValue>>&);
+
+ // Start unwrapping values.
+ //
+ // When the unwrapping completes, the loader will call MarkReady() on the
+ // request queue item.
+ void Start();
+
+ // FileReaderLoaderClient implementaton.
+ void DidStartLoading() override;
+ void DidReceiveDataForClient(const char* data, unsigned data_length) override;
+ void DidFinishLoading() override;
+ void DidFail(FileError::ErrorCode) override;
+
+ DEFINE_INLINE_TRACE() { visitor->Trace(queue_item_); }
+
+ private:
+ // Starts unwrapping the next wrapped IDBValue.
+ //
+ // If no more wrapped IDBValues are found, this calls the IDBRequest
+ // callbacks.
+ void StartNextValue();
+
+ void ReportSuccess();
+ void ReportError();
+
+ std::unique_ptr<FileReaderLoader> loader_;
+
+ // Transaction result queue item for the IDBRequest.
+ Member<IDBRequestQueueItem> queue_item_;
+
+ // All the values that will be passed back to the IDBRequest.
+ Vector<RefPtr<IDBValue>>* const values_;
+
+ // Buffer used to unwrap an IDBValue.
+ Vector<char> wrapped_data_;
+
+ // The value being currently unwrapped.
+ Vector<RefPtr<IDBValue>>::iterator current_value_;
+};
+
+} // namespace blink
+
+#endif // IDBRequestLoader_h

Powered by Google App Engine
This is Rietveld 408576698