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

Unified Diff: net/base/upload_disk_cache_entry_element_reader.h

Issue 1376123002: Revert of [Blob] BlobReader class & tests, and removal of all redundant reading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « content/content_tests.gypi ('k') | net/base/upload_disk_cache_entry_element_reader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/upload_disk_cache_entry_element_reader.h
diff --git a/net/base/upload_disk_cache_entry_element_reader.h b/net/base/upload_disk_cache_entry_element_reader.h
new file mode 100644
index 0000000000000000000000000000000000000000..1885b2e907412d5238d0ee4b205a61c4f7a7964e
--- /dev/null
+++ b/net/base/upload_disk_cache_entry_element_reader.h
@@ -0,0 +1,72 @@
+// 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 NET_BASE_UPLOAD_DISK_CACHE_ENTRY_ELEMENT_READER_H_
+#define NET_BASE_UPLOAD_DISK_CACHE_ENTRY_ELEMENT_READER_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/weak_ptr.h"
+#include "net/base/completion_callback.h"
+#include "net/base/net_export.h"
+#include "net/base/upload_element_reader.h"
+
+namespace disk_cache {
+class Entry;
+}
+
+namespace net {
+
+// An UploadElementReader implementation for disk_cache::Entry objects. The
+// caller keeps ownership of |disk_cache_entry|, and is responsible for ensuring
+// it outlives the UploadDiskCacheEntryElementReader.
+class NET_EXPORT UploadDiskCacheEntryElementReader
+ : public UploadElementReader {
+ public:
+ // Construct a new UploadDiskCacheEntryElementReader which reads from the disk
+ // cache entry |disk_cache_entry| with stream index |disk_cache_stream_index|.
+ // The new upload reader object will read |range_length| bytes, starting from
+ // |range_offset|. To read an whole cache entry give a 0 as |range_offset| and
+ // provide the length of the entry's stream as |range_length|.
+ UploadDiskCacheEntryElementReader(disk_cache::Entry* disk_cache_entry,
+ int disk_cache_stream_index,
+ int range_offset,
+ int range_length);
+ ~UploadDiskCacheEntryElementReader() override;
+
+ int range_offset_for_tests() const { return range_begin_offset_; }
+ int range_length_for_tests() const {
+ return range_end_offset_ - range_begin_offset_;
+ }
+
+ // UploadElementReader overrides:
+ const UploadDiskCacheEntryElementReader* AsDiskCacheEntryReaderForTests()
+ const override;
+ int Init(const CompletionCallback& callback) override;
+ uint64_t GetContentLength() const override;
+ uint64_t BytesRemaining() const override;
+ bool IsInMemory() const override;
+ int Read(IOBuffer* buf,
+ int buf_length,
+ const CompletionCallback& callback) override;
+
+ private:
+ void OnReadCompleted(const CompletionCallback& callback, int result);
+
+ disk_cache::Entry* const disk_cache_entry_;
+ const int disk_cache_stream_index_;
+
+ const int range_begin_offset_;
+ const int range_end_offset_;
+
+ int current_read_offset_;
+
+ base::WeakPtrFactory<UploadDiskCacheEntryElementReader> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(UploadDiskCacheEntryElementReader);
+};
+
+} // namespace net
+
+#endif // NET_BASE_UPLOAD_DISK_CACHE_ENTRY_ELEMENT_READER_H_
« no previous file with comments | « content/content_tests.gypi ('k') | net/base/upload_disk_cache_entry_element_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698