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

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

Issue 214363002: drive: Return cancel closure from FileSystem::GetFileContent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // If no data is available yet, returns net::ERR_IO_PENDING immediately, 165 // If no data is available yet, returns net::ERR_IO_PENDING immediately,
166 // and when the data is available the actual Read operation is done 166 // and when the data is available the actual Read operation is done
167 // and |callback| will be run with the result. 167 // and |callback| will be run with the result.
168 // The Read() method must not be called before the Initialize() is completed 168 // The Read() method must not be called before the Initialize() is completed
169 // successfully, or if there is pending read operation. 169 // successfully, or if there is pending read operation.
170 // Neither |buffer| nor |callback| must be null. 170 // Neither |buffer| nor |callback| must be null.
171 int Read(net::IOBuffer* buffer, int buffer_length, 171 int Read(net::IOBuffer* buffer, int buffer_length,
172 const net::CompletionCallback& callback); 172 const net::CompletionCallback& callback);
173 173
174 private: 174 private:
175 // Used to store the cancel closure returned by FileSystemInterface.
176 void StoreCancelDownloadClosure(const base::Closure& cancel_download_closure);
177
175 // Part of Initialize. Called after GetFileContent's initialization 178 // Part of Initialize. Called after GetFileContent's initialization
176 // is done. 179 // is done.
177 void InitializeAfterGetFileContentInitialized( 180 void InitializeAfterGetFileContentInitialized(
178 const net::HttpByteRange& byte_range, 181 const net::HttpByteRange& byte_range,
179 const InitializeCompletionCallback& callback, 182 const InitializeCompletionCallback& callback,
180 FileError error, 183 FileError error,
181 scoped_ptr<ResourceEntry> entry,
182 const base::FilePath& local_cache_file_path, 184 const base::FilePath& local_cache_file_path,
183 const base::Closure& cancel_download_closure); 185 scoped_ptr<ResourceEntry> entry);
184 186
185 // Part of Initialize. Called when the local file open process is done. 187 // Part of Initialize. Called when the local file open process is done.
186 void InitializeAfterLocalFileOpen( 188 void InitializeAfterLocalFileOpen(
187 int64 length, 189 int64 length,
188 const InitializeCompletionCallback& callback, 190 const InitializeCompletionCallback& callback,
189 scoped_ptr<ResourceEntry> entry, 191 scoped_ptr<ResourceEntry> entry,
190 scoped_ptr<util::LocalFileReader> file_reader, 192 scoped_ptr<util::LocalFileReader> file_reader,
191 int open_result); 193 int open_result);
192 194
193 // Called when the data is received from the server. 195 // Called when the data is received from the server.
194 void OnGetContent(google_apis::GDataErrorCode error_code, 196 void OnGetContent(google_apis::GDataErrorCode error_code,
195 scoped_ptr<std::string> data); 197 scoped_ptr<std::string> data);
196 198
197 // Called when GetFileContent is completed. 199 // Called when GetFileContent is completed.
198 void OnGetFileContentCompletion( 200 void OnGetFileContentCompletion(
199 const InitializeCompletionCallback& callback, 201 const InitializeCompletionCallback& callback,
200 FileError error); 202 FileError error);
201 203
202 const FileSystemGetter file_system_getter_; 204 const FileSystemGetter file_system_getter_;
203 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; 205 scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
206 base::Closure cancel_download_closure_;
204 scoped_ptr<internal::ReaderProxy> reader_proxy_; 207 scoped_ptr<internal::ReaderProxy> reader_proxy_;
205 208
206 // This should remain the last member so it'll be destroyed first and 209 // This should remain the last member so it'll be destroyed first and
207 // invalidate its weak pointers before other members are destroyed. 210 // invalidate its weak pointers before other members are destroyed.
208 base::WeakPtrFactory<DriveFileStreamReader> weak_ptr_factory_; 211 base::WeakPtrFactory<DriveFileStreamReader> weak_ptr_factory_;
209 DISALLOW_COPY_AND_ASSIGN(DriveFileStreamReader); 212 DISALLOW_COPY_AND_ASSIGN(DriveFileStreamReader);
210 }; 213 };
211 214
212 } // namespace drive 215 } // namespace drive
213 216
214 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_ 217 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698