OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_DRIVE_DRIVE_FILE_STREAM_READER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // The |file_reader| should be the instance which is already opened. | 56 // The |file_reader| should be the instance which is already opened. |
57 // This class takes its ownership. | 57 // This class takes its ownership. |
58 // |length| is the number of bytes to be read. It must be equal or | 58 // |length| is the number of bytes to be read. It must be equal or |
59 // smaller than the remaining data size in the |file_reader|. | 59 // smaller than the remaining data size in the |file_reader|. |
60 LocalReaderProxy( | 60 LocalReaderProxy( |
61 scoped_ptr<util::LocalFileReader> file_reader, int64 length); | 61 scoped_ptr<util::LocalFileReader> file_reader, int64 length); |
62 virtual ~LocalReaderProxy(); | 62 virtual ~LocalReaderProxy(); |
63 | 63 |
64 // ReaderProxy overrides. | 64 // ReaderProxy overrides. |
65 virtual int Read(net::IOBuffer* buffer, int buffer_length, | 65 virtual int Read(net::IOBuffer* buffer, int buffer_length, |
66 const net::CompletionCallback& callback) OVERRIDE; | 66 const net::CompletionCallback& callback) override; |
67 virtual void OnGetContent(scoped_ptr<std::string> data) OVERRIDE; | 67 virtual void OnGetContent(scoped_ptr<std::string> data) override; |
68 virtual void OnCompleted(FileError error) OVERRIDE; | 68 virtual void OnCompleted(FileError error) override; |
69 | 69 |
70 private: | 70 private: |
71 scoped_ptr<util::LocalFileReader> file_reader_; | 71 scoped_ptr<util::LocalFileReader> file_reader_; |
72 | 72 |
73 // Callback for the LocalFileReader::Read. | 73 // Callback for the LocalFileReader::Read. |
74 void OnReadCompleted( | 74 void OnReadCompleted( |
75 const net::CompletionCallback& callback, int read_result); | 75 const net::CompletionCallback& callback, int read_result); |
76 | 76 |
77 // The number of remaining bytes to be read. | 77 // The number of remaining bytes to be read. |
78 int64 remaining_length_; | 78 int64 remaining_length_; |
(...skipping 11 matching lines...) Expand all Loading... |
90 // to cancel the job. |job_canceller| should be the callback to run the | 90 // to cancel the job. |job_canceller| should be the callback to run the |
91 // cancelling. |full_content_length| is necessary for determining whether the | 91 // cancelling. |full_content_length| is necessary for determining whether the |
92 // deletion is done in the middle of download process. | 92 // deletion is done in the middle of download process. |
93 NetworkReaderProxy( | 93 NetworkReaderProxy( |
94 int64 offset, int64 content_length, int64 full_content_length, | 94 int64 offset, int64 content_length, int64 full_content_length, |
95 const base::Closure& job_canceller); | 95 const base::Closure& job_canceller); |
96 virtual ~NetworkReaderProxy(); | 96 virtual ~NetworkReaderProxy(); |
97 | 97 |
98 // ReaderProxy overrides. | 98 // ReaderProxy overrides. |
99 virtual int Read(net::IOBuffer* buffer, int buffer_length, | 99 virtual int Read(net::IOBuffer* buffer, int buffer_length, |
100 const net::CompletionCallback& callback) OVERRIDE; | 100 const net::CompletionCallback& callback) override; |
101 virtual void OnGetContent(scoped_ptr<std::string> data) OVERRIDE; | 101 virtual void OnGetContent(scoped_ptr<std::string> data) override; |
102 virtual void OnCompleted(FileError error) OVERRIDE; | 102 virtual void OnCompleted(FileError error) override; |
103 | 103 |
104 private: | 104 private: |
105 // The data received from the server, but not yet read. | 105 // The data received from the server, but not yet read. |
106 ScopedVector<std::string> pending_data_; | 106 ScopedVector<std::string> pending_data_; |
107 | 107 |
108 // The number of bytes to be skipped. | 108 // The number of bytes to be skipped. |
109 int64 remaining_offset_; | 109 int64 remaining_offset_; |
110 | 110 |
111 // The number of bytes of remaining data (including the data not yet | 111 // The number of bytes of remaining data (including the data not yet |
112 // received from the server). | 112 // received from the server). |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 214 |
215 // This should remain the last member so it'll be destroyed first and | 215 // This should remain the last member so it'll be destroyed first and |
216 // invalidate its weak pointers before other members are destroyed. | 216 // invalidate its weak pointers before other members are destroyed. |
217 base::WeakPtrFactory<DriveFileStreamReader> weak_ptr_factory_; | 217 base::WeakPtrFactory<DriveFileStreamReader> weak_ptr_factory_; |
218 DISALLOW_COPY_AND_ASSIGN(DriveFileStreamReader); | 218 DISALLOW_COPY_AND_ASSIGN(DriveFileStreamReader); |
219 }; | 219 }; |
220 | 220 |
221 } // namespace drive | 221 } // namespace drive |
222 | 222 |
223 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_ | 223 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_ |
OLD | NEW |