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

Unified Diff: chrome/browser/chromeos/file_system_provider/fileapi/buffering_file_stream_reader.h

Issue 470323003: [fsp] Improve performance for reading small chunks of data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 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: chrome/browser/chromeos/file_system_provider/fileapi/buffering_file_stream_reader.h
diff --git a/chrome/browser/chromeos/file_system_provider/fileapi/buffering_file_stream_reader.h b/chrome/browser/chromeos/file_system_provider/fileapi/buffering_file_stream_reader.h
index 58c90e38aa0b35922235cd6356011e8264fd15e1..cbb2aa8ef31713de6040057cabee2db65eec40a9 100644
--- a/chrome/browser/chromeos/file_system_provider/fileapi/buffering_file_stream_reader.h
+++ b/chrome/browser/chromeos/file_system_provider/fileapi/buffering_file_stream_reader.h
@@ -20,16 +20,18 @@ namespace file_system_provider {
// Wraps the file stream reader implementation with a prefetching buffer.
// Reads data from the internal file stream reader in chunks of size at least
-// |buffer_size| bytes (or less for the last chunk, because of EOF).
+// |preloading_buffer_length| bytes (or less for the last chunk, because of
+// EOF). Up to |max_bytes_to_read| of bytes can be requested in total.
//
-// The underlying inner file stream reader *must not* return any values
+// The underlying internal file stream reader *must not* return any values
// synchronously. Instead, results must be returned by a callback, including
// errors.
class BufferingFileStreamReader : public storage::FileStreamReader {
public:
BufferingFileStreamReader(
scoped_ptr<storage::FileStreamReader> file_stream_reader,
- int buffer_size);
+ int preloading_buffer_length,
+ int64 max_bytes_to_read);
virtual ~BufferingFileStreamReader();
@@ -49,6 +51,8 @@ class BufferingFileStreamReader : public storage::FileStreamReader {
// Preloads data from the internal stream reader and calls the |callback|.
void Preload(const net::CompletionCallback& callback);
+ void OnReadCompleted(const net::CompletionCallback& callback, int result);
+
// Called when preloading of a buffer chunk is finished. Updates state of the
// preloading buffer and copied requested data to the |buffer|.
void OnPreloadCompleted(scoped_refptr<net::IOBuffer> buffer,
@@ -57,10 +61,12 @@ class BufferingFileStreamReader : public storage::FileStreamReader {
int result);
scoped_ptr<storage::FileStreamReader> file_stream_reader_;
- int buffer_size_;
+ int preloading_buffer_length_;
+ int64 max_bytes_to_read_;
+ int64 bytes_read_;
scoped_refptr<net::IOBuffer> preloading_buffer_;
int preloading_buffer_offset_;
- int buffered_bytes_;
+ int preloaded_bytes_;
base::WeakPtrFactory<BufferingFileStreamReader> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(BufferingFileStreamReader);

Powered by Google App Engine
This is Rietveld 408576698