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

Unified Diff: storage/browser/blob/upload_blob_element_reader.h

Issue 1337153002: [Blob] BlobReader class & tests, and removal of all redundant reading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed prod/debug flakiness Created 5 years, 3 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: storage/browser/blob/upload_blob_element_reader.h
diff --git a/storage/browser/blob/upload_blob_element_reader.h b/storage/browser/blob/upload_blob_element_reader.h
new file mode 100644
index 0000000000000000000000000000000000000000..72b7244a486c0d7c02322caa442cc45916424cd3
--- /dev/null
+++ b/storage/browser/blob/upload_blob_element_reader.h
@@ -0,0 +1,54 @@
+// Copyright 2015 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 STORAGE_BROWSER_BLOB_UPLOAD_BLOB_ELEMENT_READER_H_
+#define STORAGE_BROWSER_BLOB_UPLOAD_BLOB_ELEMENT_READER_H_
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "net/base/completion_callback.h"
+#include "net/base/upload_element_reader.h"
+#include "storage/browser/storage_browser_export.h"
+
+namespace net {
+class IOBuffer;
+}
+
+namespace storage {
+class BlobDataHandle;
+class BlobReader;
+
+// This class is a wrapper around the BlobReader to make it conform
+// to the net::UploadElementReader interface, and it also holds around the
+// handle to the blob so it stays in memory while we read it.
+class STORAGE_EXPORT UploadBlobElementReader
+ : NON_EXPORTED_BASE(public net::UploadElementReader) {
+ public:
+ UploadBlobElementReader(scoped_ptr<BlobReader> reader,
+ scoped_ptr<BlobDataHandle> handle);
+ ~UploadBlobElementReader() override;
+
+ int Init(const net::CompletionCallback& callback) override;
+
+ uint64_t GetContentLength() const override;
+
+ uint64_t BytesRemaining() const override;
+
+ bool IsInMemory() const override;
+
+ int Read(net::IOBuffer* buf,
+ int buf_length,
+ const net::CompletionCallback& callback) override;
+
+ const std::string& uuid() const;
+
+ private:
+ scoped_ptr<BlobReader> reader_;
+ scoped_ptr<BlobDataHandle> handle_;
+
+ DISALLOW_COPY_AND_ASSIGN(UploadBlobElementReader);
+};
+
+} // namespace storage
+#endif // STORAGE_BROWSER_BLOB_UPLOAD_BLOB_ELEMENT_READER_H_
« no previous file with comments | « storage/browser/blob/blob_url_request_job_factory.cc ('k') | storage/browser/blob/upload_blob_element_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698