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

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: even narrower 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..9c7894e820d7b7144ed8bea3eb61efc15d5cd542
--- /dev/null
+++ b/net/base/upload_disk_cache_entry_element_reader.h
@@ -0,0 +1,63 @@
+// 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/upload_element_reader.h"
+
+namespace disk_cache {
+class Entry;
+}
+
+namespace net {
+
+// An UploadElementReader implementation for disk_cache::Entry objects.
+// |entry| should outlive this class because this class does not take the
+// ownership of the data.
mmenke 2015/06/16 18:51:18 Think the second sentence should be more assertive
gavinp 2015/06/16 22:28:01 Done. This text was copied directly from upload_by
+class NET_EXPORT UploadDiskCacheEntryElementReader
mmenke 2015/06/16 18:51:18 include net_export
gavinp 2015/06/16 22:28:01 Done. Also in the file and bytes upload element he
+ : public UploadElementReader {
+ public:
+ UploadDiskCacheEntryElementReader(disk_cache::Entry* disk_cache_entry,
+ int disk_cache_stream_index,
+ int range_offset,
+ int range_length);
mmenke 2015/06/16 18:51:18 These are fine as ints, rather than int64s? Not s
gavinp 2015/06/16 22:28:01 The disk_cache interface uses ints, and so I chose
+ ~UploadDiskCacheEntryElementReader() override;
+
+ int range_offset() const { return range_offset_; }
+ int range_length() const { return range_length_; }
mmenke 2015/06/16 18:51:19 +_for_testing / _for_tests
gavinp 2015/06/16 22:28:01 Done.
+
+ // UploadElementReader overrides:
+ const UploadDiskCacheEntryElementReader* AsDiskCacheEntryReader()
mmenke 2015/06/16 18:51:18 These methods make me sad. :( The other UploadEl
gavinp 2015/06/16 22:28:01 Done. I don't think we want to let extensions poke
+ const override;
+ int Init(const CompletionCallback& callback) override;
mmenke 2015/06/16 18:51:18 I generally feel like you should forward declare a
gavinp 2015/06/16 22:28:01 I'm happy to do this; I was of the impression that
+ 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_offset_;
+ const int range_length_;
+
+ int offset_;
mmenke 2015/06/16 18:51:18 Should document these. It's not clear, in particu
michaeln 2015/06/16 21:52:54 +1 comments &| massaging the names, wasn't obvsiou
gavinp 2015/06/16 22:28:01 I've done this. I left the inline methods used in
+
+ 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