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

Side by Side Diff: chrome/browser/chromeos/drive/drive_file_stream_reader.h

Issue 291483005: drive: Discard stream reader canceller as soon as the required data is obtained. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_file_stream_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // invalidate its weak pointers before other members are destroyed. 81 // invalidate its weak pointers before other members are destroyed.
82 base::WeakPtrFactory<LocalReaderProxy> weak_ptr_factory_; 82 base::WeakPtrFactory<LocalReaderProxy> weak_ptr_factory_;
83 DISALLOW_COPY_AND_ASSIGN(LocalReaderProxy); 83 DISALLOW_COPY_AND_ASSIGN(LocalReaderProxy);
84 }; 84 };
85 85
86 // The read operation implementation for the file which is being downloaded. 86 // The read operation implementation for the file which is being downloaded.
87 class NetworkReaderProxy : public ReaderProxy { 87 class NetworkReaderProxy : public ReaderProxy {
88 public: 88 public:
89 // If the instance is deleted during the download process, it is necessary 89 // If the instance is deleted during the download process, it is necessary
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. 91 // cancelling. |full_content_length| is necessary for determining whether the
92 // deletion is done in the middle of download process.
92 NetworkReaderProxy( 93 NetworkReaderProxy(
93 int64 offset, int64 content_length, const base::Closure& job_canceller); 94 int64 offset, int64 content_length, int64 full_content_length,
95 const base::Closure& job_canceller);
94 virtual ~NetworkReaderProxy(); 96 virtual ~NetworkReaderProxy();
95 97
96 // ReaderProxy overrides. 98 // ReaderProxy overrides.
97 virtual int Read(net::IOBuffer* buffer, int buffer_length, 99 virtual int Read(net::IOBuffer* buffer, int buffer_length,
98 const net::CompletionCallback& callback) OVERRIDE; 100 const net::CompletionCallback& callback) OVERRIDE;
99 virtual void OnGetContent(scoped_ptr<std::string> data) OVERRIDE; 101 virtual void OnGetContent(scoped_ptr<std::string> data) OVERRIDE;
100 virtual void OnCompleted(FileError error) OVERRIDE; 102 virtual void OnCompleted(FileError error) OVERRIDE;
101 103
102 private: 104 private:
103 // The data received from the server, but not yet read. 105 // The data received from the server, but not yet read.
104 ScopedVector<std::string> pending_data_; 106 ScopedVector<std::string> pending_data_;
105 107
106 // The number of bytes to be skipped. 108 // The number of bytes to be skipped.
107 int64 remaining_offset_; 109 int64 remaining_offset_;
108 110
109 // 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
110 // received from the server). 112 // received from the server).
111 int64 remaining_content_length_; 113 int64 remaining_content_length_;
112 114
115 // Flag to remember whether this read request is for reading till the end of
116 // the file.
117 const bool is_full_download_;
118
113 int error_code_; 119 int error_code_;
114 120
115 // To support pending Read(), it is necessary to keep its arguments. 121 // To support pending Read(), it is necessary to keep its arguments.
116 scoped_refptr<net::IOBuffer> buffer_; 122 scoped_refptr<net::IOBuffer> buffer_;
117 int buffer_length_; 123 int buffer_length_;
118 net::CompletionCallback callback_; 124 net::CompletionCallback callback_;
119 125
120 // Keeps the closure to cancel downloading job if necessary. 126 // Keeps the closure to cancel downloading job if necessary.
121 // Will be reset when the job is completed (regardless whether the job is 127 // Will be reset when the job is completed (regardless whether the job is
122 // successfully done or not). 128 // successfully done or not).
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 214
209 // 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
210 // invalidate its weak pointers before other members are destroyed. 216 // invalidate its weak pointers before other members are destroyed.
211 base::WeakPtrFactory<DriveFileStreamReader> weak_ptr_factory_; 217 base::WeakPtrFactory<DriveFileStreamReader> weak_ptr_factory_;
212 DISALLOW_COPY_AND_ASSIGN(DriveFileStreamReader); 218 DISALLOW_COPY_AND_ASSIGN(DriveFileStreamReader);
213 }; 219 };
214 220
215 } // namespace drive 221 } // namespace drive
216 222
217 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_ 223 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_file_stream_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698