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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/fileapi/buffering_file_stream_reader.h

Issue 1547093002: Switch to standard integer types in chrome/browser/chromeos/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_BUFFERING_FILE_STRE AM_READER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_BUFFERING_FILE_STRE AM_READER_H_
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_BUFFERING_FILE_STRE AM_READER_H_ 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_BUFFERING_FILE_STRE AM_READER_H_
7 7
8 #include "base/basictypes.h" 8 #include <stdint.h>
9
10 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
12 #include "storage/browser/fileapi/file_stream_reader.h" 14 #include "storage/browser/fileapi/file_stream_reader.h"
13 15
14 namespace net { 16 namespace net {
15 class IOBuffer; 17 class IOBuffer;
16 } // namespace net 18 } // namespace net
17 19
18 namespace chromeos { 20 namespace chromeos {
19 namespace file_system_provider { 21 namespace file_system_provider {
20 22
21 // Wraps the file stream reader implementation with a prefetching buffer. 23 // Wraps the file stream reader implementation with a prefetching buffer.
22 // Reads data from the internal file stream reader in chunks of size at least 24 // Reads data from the internal file stream reader in chunks of size at least
23 // |preloading_buffer_length| bytes (or less for the last chunk, because of 25 // |preloading_buffer_length| bytes (or less for the last chunk, because of
24 // EOF). Up to |max_bytes_to_read| of bytes can be requested in total. 26 // EOF). Up to |max_bytes_to_read| of bytes can be requested in total.
25 // 27 //
26 // The underlying internal file stream reader *must not* return any values 28 // The underlying internal file stream reader *must not* return any values
27 // synchronously. Instead, results must be returned by a callback, including 29 // synchronously. Instead, results must be returned by a callback, including
28 // errors. 30 // errors.
29 class BufferingFileStreamReader : public storage::FileStreamReader { 31 class BufferingFileStreamReader : public storage::FileStreamReader {
30 public: 32 public:
31 BufferingFileStreamReader( 33 BufferingFileStreamReader(
32 scoped_ptr<storage::FileStreamReader> file_stream_reader, 34 scoped_ptr<storage::FileStreamReader> file_stream_reader,
33 int preloading_buffer_length, 35 int preloading_buffer_length,
34 int64 max_bytes_to_read); 36 int64_t max_bytes_to_read);
35 37
36 ~BufferingFileStreamReader() override; 38 ~BufferingFileStreamReader() override;
37 39
38 // storage::FileStreamReader overrides. 40 // storage::FileStreamReader overrides.
39 int Read(net::IOBuffer* buf, 41 int Read(net::IOBuffer* buf,
40 int buf_len, 42 int buf_len,
41 const net::CompletionCallback& callback) override; 43 const net::CompletionCallback& callback) override;
42 int64 GetLength(const net::Int64CompletionCallback& callback) override; 44 int64_t GetLength(const net::Int64CompletionCallback& callback) override;
43 45
44 private: 46 private:
45 // Copies data from the preloading buffer and updates the internal iterator. 47 // Copies data from the preloading buffer and updates the internal iterator.
46 // Returns number of bytes successfully copied. 48 // Returns number of bytes successfully copied.
47 int CopyFromPreloadingBuffer(scoped_refptr<net::IOBuffer> buffer, 49 int CopyFromPreloadingBuffer(scoped_refptr<net::IOBuffer> buffer,
48 int buffer_length); 50 int buffer_length);
49 51
50 // Preloads data from the internal stream reader and calls the |callback|. 52 // Preloads data from the internal stream reader and calls the |callback|.
51 void Preload(const net::CompletionCallback& callback); 53 void Preload(const net::CompletionCallback& callback);
52 54
53 void OnReadCompleted(const net::CompletionCallback& callback, int result); 55 void OnReadCompleted(const net::CompletionCallback& callback, int result);
54 56
55 // Called when preloading of a buffer chunk is finished. Updates state of the 57 // Called when preloading of a buffer chunk is finished. Updates state of the
56 // preloading buffer and copied requested data to the |buffer|. 58 // preloading buffer and copied requested data to the |buffer|.
57 void OnPreloadCompleted(scoped_refptr<net::IOBuffer> buffer, 59 void OnPreloadCompleted(scoped_refptr<net::IOBuffer> buffer,
58 int buffer_length, 60 int buffer_length,
59 const net::CompletionCallback& callback, 61 const net::CompletionCallback& callback,
60 int result); 62 int result);
61 63
62 scoped_ptr<storage::FileStreamReader> file_stream_reader_; 64 scoped_ptr<storage::FileStreamReader> file_stream_reader_;
63 int preloading_buffer_length_; 65 int preloading_buffer_length_;
64 int64 max_bytes_to_read_; 66 int64_t max_bytes_to_read_;
65 int64 bytes_read_; 67 int64_t bytes_read_;
66 scoped_refptr<net::IOBuffer> preloading_buffer_; 68 scoped_refptr<net::IOBuffer> preloading_buffer_;
67 int preloading_buffer_offset_; 69 int preloading_buffer_offset_;
68 int preloaded_bytes_; 70 int preloaded_bytes_;
69 71
70 base::WeakPtrFactory<BufferingFileStreamReader> weak_ptr_factory_; 72 base::WeakPtrFactory<BufferingFileStreamReader> weak_ptr_factory_;
71 DISALLOW_COPY_AND_ASSIGN(BufferingFileStreamReader); 73 DISALLOW_COPY_AND_ASSIGN(BufferingFileStreamReader);
72 }; 74 };
73 75
74 } // namespace file_system_provider 76 } // namespace file_system_provider
75 } // namespace chromeos 77 } // namespace chromeos
76 78
77 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_BUFFERING_FILE_S TREAM_READER_H_ 79 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_BUFFERING_FILE_S TREAM_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698