OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_GOOGLE_APIS_DRIVE_UPLOADER_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_DRIVE_UPLOADER_H_ |
6 #define CHROME_BROWSER_GOOGLE_APIS_DRIVE_UPLOADER_H_ | 6 #define CHROME_BROWSER_GOOGLE_APIS_DRIVE_UPLOADER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // net::FileStream::Open completion callback. The result of the file open | 109 // net::FileStream::Open completion callback. The result of the file open |
110 // operation is passed as |result|, and the size is stored in |file_size|. | 110 // operation is passed as |result|, and the size is stored in |file_size|. |
111 void OpenCompletionCallback(scoped_ptr<UploadFileInfo> upload_file_info, | 111 void OpenCompletionCallback(scoped_ptr<UploadFileInfo> upload_file_info, |
112 int64 file_size); | 112 int64 file_size); |
113 | 113 |
114 // DriveService callback for InitiateUpload. | 114 // DriveService callback for InitiateUpload. |
115 void OnUploadLocationReceived(scoped_ptr<UploadFileInfo> upload_file_info, | 115 void OnUploadLocationReceived(scoped_ptr<UploadFileInfo> upload_file_info, |
116 GDataErrorCode code, | 116 GDataErrorCode code, |
117 const GURL& upload_location); | 117 const GURL& upload_location); |
118 | 118 |
| 119 // Uploads the remaining data in the current chunk. |
| 120 // The |restart_position| is the file's position to be restart for uploading. |
| 121 void UploadCurrentChunk( |
| 122 scoped_ptr<UploadFileInfo> upload_file_info, int64 restart_position); |
| 123 |
119 // Uploads the next chunk of data from the file. | 124 // Uploads the next chunk of data from the file. |
120 void UploadNextChunk(scoped_ptr<UploadFileInfo> upload_file_info); | 125 void UploadNextChunk(scoped_ptr<UploadFileInfo> upload_file_info); |
121 | 126 |
122 // net::FileStream::Read completion callback. | 127 // net::FileStream::Read completion callback. |
123 void ReadCompletionCallback(scoped_ptr<UploadFileInfo> upload_file_info, | 128 void ReadCompletionCallback(scoped_ptr<UploadFileInfo> upload_file_info, |
124 int bytes_to_read, | 129 int bytes_to_read, |
125 int bytes_read); | 130 int bytes_read); |
126 | 131 |
127 // Calls DriveService's ResumeUpload with the current upload info. | 132 // Calls DriveService's ResumeUpload with the current upload info. |
128 void ResumeUpload(scoped_ptr<UploadFileInfo> upload_file_info, | 133 void ResumeUpload(scoped_ptr<UploadFileInfo> upload_file_info, |
129 int bytes_to_send); | 134 int bytes_to_send); |
130 | 135 |
131 // DriveService callback for ResumeUpload. | 136 // DriveService callback for ResumeUpload and GetUploadState. |
132 void OnResumeUploadResponseReceived( | 137 void OnResumeUploadResponseReceived( |
133 scoped_ptr<UploadFileInfo> upload_file_info, | 138 scoped_ptr<UploadFileInfo> upload_file_info, |
134 const ResumeUploadResponse& response, | 139 const ResumeUploadResponse& response, |
135 scoped_ptr<ResourceEntry> entry); | 140 scoped_ptr<ResourceEntry> entry); |
136 | 141 |
| 142 // Resumes the uploading interrupted by HTTP 5xx response. |
| 143 // To avoid receiving the server errors repeatedly, this method waits |
| 144 // for a while before actual resuming. |
| 145 void ResumeInterruptedUpload( |
| 146 scoped_ptr<UploadFileInfo> upload_file_info); |
| 147 |
| 148 // This method processes the remaining tasks to resume the uploading |
| 149 // after waiting followed by ResumeInterruptedUpload. |
| 150 void ResumeInterruptedUploadAfterWaiting( |
| 151 scoped_ptr<UploadFileInfo> upload_file_info); |
| 152 |
137 // Handle failed uploads. | 153 // Handle failed uploads. |
138 void UploadFailed(scoped_ptr<UploadFileInfo> upload_file_info, | 154 void UploadFailed(scoped_ptr<UploadFileInfo> upload_file_info, |
139 DriveUploadError error); | 155 DriveUploadError error); |
140 | 156 |
141 // Pointers to DriveServiceInterface object owned by DriveSystemService. | 157 // Pointers to DriveServiceInterface object owned by DriveSystemService. |
142 // The lifetime of this object is guaranteed to exceed that of the | 158 // The lifetime of this object is guaranteed to exceed that of the |
143 // DriveUploader instance. | 159 // DriveUploader instance. |
144 DriveServiceInterface* drive_service_; | 160 DriveServiceInterface* drive_service_; |
145 | 161 |
146 // TaskRunner for opening, reading, and closing files. | 162 // TaskRunner for opening, reading, and closing files. |
147 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 163 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
148 | 164 |
149 // Note: This should remain the last member so it'll be destroyed and | 165 // Note: This should remain the last member so it'll be destroyed and |
150 // invalidate its weak pointers before any other members are destroyed. | 166 // invalidate its weak pointers before any other members are destroyed. |
151 base::WeakPtrFactory<DriveUploader> weak_ptr_factory_; | 167 base::WeakPtrFactory<DriveUploader> weak_ptr_factory_; |
152 | 168 |
153 DISALLOW_COPY_AND_ASSIGN(DriveUploader); | 169 DISALLOW_COPY_AND_ASSIGN(DriveUploader); |
154 }; | 170 }; |
155 | 171 |
156 } // namespace google_apis | 172 } // namespace google_apis |
157 | 173 |
158 #endif // CHROME_BROWSER_GOOGLE_APIS_DRIVE_UPLOADER_H_ | 174 #endif // CHROME_BROWSER_GOOGLE_APIS_DRIVE_UPLOADER_H_ |
OLD | NEW |