| 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_URL_REQUEST_JOB_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_URL_REQUEST_JOB_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_URL_REQUEST_JOB_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_URL_REQUEST_JOB_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // Helper callback for GetEntryInfoByResourceId invoked by Start(). | 88 // Helper callback for GetEntryInfoByResourceId invoked by Start(). |
| 89 void OnGetEntryInfoByResourceId(const std::string& resource_id, | 89 void OnGetEntryInfoByResourceId(const std::string& resource_id, |
| 90 DriveFileError error, | 90 DriveFileError error, |
| 91 const base::FilePath& drive_file_path, | 91 const base::FilePath& drive_file_path, |
| 92 scoped_ptr<DriveEntryProto> entry_proto); | 92 scoped_ptr<DriveEntryProto> entry_proto); |
| 93 | 93 |
| 94 // Helper methods for ReadRawData to open file and read from its corresponding | 94 // Helper methods for ReadRawData to open file and read from its corresponding |
| 95 // stream in a streaming fashion. | 95 // stream in a streaming fashion. |
| 96 bool ContinueReadFromFile(int* bytes_read); | 96 bool ContinueReadFromFile(int* bytes_read); |
| 97 void ReadFromFile(); | 97 void ReadFromFile(); |
| 98 void ReadFileStream(int bytes_to_read); | 98 void ReadFileStream(); |
| 99 | 99 |
| 100 // Helper callback for handling async responses from FileStream::Open(). | 100 // Helper callback for handling async responses from FileStream::Open(). |
| 101 void OnFileOpen(int bytes_to_read, int open_result); | 101 void OnFileOpen(int open_result); |
| 102 | 102 |
| 103 // Helper callback for handling async responses from FileStream::Read(). | 103 // Helper callback for handling async responses from FileStream::Read(). |
| 104 void OnReadFileStream(int bytes_read); | 104 void OnReadFileStream(int bytes_read); |
| 105 | 105 |
| 106 // Helper methods to handle |reamining_bytes_| and |read_buf_|. | 106 // Helper methods to handle |reamining_bytes_| and |read_buf_|. |
| 107 int BytesReadCompleted(); | 107 int BytesReadCompleted(); |
| 108 void RecordBytesRead(int bytes_read); | 108 void RecordBytesRead(int bytes_read); |
| 109 | 109 |
| 110 // Helper methods to formulate and notify about response status, info and | 110 // Helper methods to formulate and notify about response status, info and |
| 111 // headers. | 111 // headers. |
| 112 void NotifySuccess(); | 112 void NotifySuccess(); |
| 113 void NotifyFailure(int); | 113 void NotifyFailure(int); |
| 114 void HeadersCompleted(int status_code, const std::string& status_txt); | 114 void HeadersCompleted(int status_code, const std::string& status_txt); |
| 115 | 115 |
| 116 // Helper method to close |stream_|. | 116 // Helper method to close |stream_|. |
| 117 void CloseFileStream(); | 117 void CloseFileStream(); |
| 118 | 118 |
| 119 DriveFileSystemGetter file_system_getter_; | 119 DriveFileSystemGetter file_system_getter_; |
| 120 | 120 |
| 121 bool error_; // True if we've encountered an error. | 121 bool error_; // True if we've encountered an error. |
| 122 bool headers_set_; // True if headers have been set. | 122 bool headers_set_; // True if headers have been set. |
| 123 | 123 |
| 124 base::FilePath local_file_path_; | 124 base::FilePath local_file_path_; |
| 125 base::FilePath drive_file_path_; | 125 base::FilePath drive_file_path_; |
| 126 std::string mime_type_; | 126 std::string mime_type_; |
| 127 int64 initial_file_size_; | 127 int64 initial_file_size_; |
| 128 int64 remaining_bytes_; | 128 int64 remaining_bytes_; |
| 129 scoped_ptr<net::FileStream> stream_; | 129 scoped_ptr<net::FileStream> stream_; |
| 130 scoped_ptr<net::HttpResponseInfo> response_info_; |
| 131 bool streaming_download_; |
| 130 scoped_refptr<net::IOBuffer> read_buf_; | 132 scoped_refptr<net::IOBuffer> read_buf_; |
| 131 base::StringPiece read_buf_remaining_; | 133 base::StringPiece read_buf_remaining_; |
| 132 scoped_ptr<net::HttpResponseInfo> response_info_; | |
| 133 bool streaming_download_; | |
| 134 std::string download_buf_; | 134 std::string download_buf_; |
| 135 base::StringPiece download_buf_remaining_; | 135 base::StringPiece download_buf_remaining_; |
| 136 | 136 |
| 137 // This should remain the last member so it'll be destroyed first and | 137 // This should remain the last member so it'll be destroyed first and |
| 138 // invalidate its weak pointers before other members are destroyed. | 138 // invalidate its weak pointers before other members are destroyed. |
| 139 base::WeakPtrFactory<DriveURLRequestJob> weak_ptr_factory_; | 139 base::WeakPtrFactory<DriveURLRequestJob> weak_ptr_factory_; |
| 140 DISALLOW_COPY_AND_ASSIGN(DriveURLRequestJob); | 140 DISALLOW_COPY_AND_ASSIGN(DriveURLRequestJob); |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 } // namespace drive | 143 } // namespace drive |
| 144 | 144 |
| 145 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_URL_REQUEST_JOB_H_ | 145 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_URL_REQUEST_JOB_H_ |
| OLD | NEW |