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

Unified Diff: net/base/upload_disk_cache_entry_element_reader.h

Issue 1108083002: Create blobs from Disk Cache entries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: omg, fix the correct base::Unretained... Created 5 years, 6 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: 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..1b1378761837eb30a252e0556dc37168e041bba8
--- /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 only read those bytes from |range_offset|
mmenke 2015/06/17 19:11:16 Should be "... will only read those bytes *startin
gavinp 2015/06/18 18:50:55 Done. Much better phrasing.
+ // and will provide |range_length| bytes. To read the entire entry give a 0 as
+ // |range_offset| and provide |range_length| as the length the entry's stream.
mmenke 2015/06/17 19:11:16 nit: "...and prove the length of the entry's strea
gavinp 2015/06/18 18:50:55 Done, using "provide" instead of "prove."
+ 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_

Powered by Google App Engine
This is Rietveld 408576698