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 #include "chrome/browser/drive/drive_uploader.h" | 5 #include "chrome/browser/drive/drive_uploader.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 } | 193 } |
194 | 194 |
195 CancelCallback DriveUploader::StartUploadFile( | 195 CancelCallback DriveUploader::StartUploadFile( |
196 scoped_ptr<UploadFileInfo> upload_file_info, | 196 scoped_ptr<UploadFileInfo> upload_file_info, |
197 const StartInitiateUploadCallback& start_initiate_upload_callback) { | 197 const StartInitiateUploadCallback& start_initiate_upload_callback) { |
198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
199 DVLOG(1) << "Uploading file: " << upload_file_info->DebugString(); | 199 DVLOG(1) << "Uploading file: " << upload_file_info->DebugString(); |
200 | 200 |
201 UploadFileInfo* info_ptr = upload_file_info.get(); | 201 UploadFileInfo* info_ptr = upload_file_info.get(); |
202 base::PostTaskAndReplyWithResult( | 202 base::PostTaskAndReplyWithResult( |
203 blocking_task_runner_, | 203 blocking_task_runner_.get(), |
204 FROM_HERE, | 204 FROM_HERE, |
205 base::Bind(&file_util::GetFileSize, info_ptr->file_path, | 205 base::Bind(&file_util::GetFileSize, |
| 206 info_ptr->file_path, |
206 &info_ptr->content_length), | 207 &info_ptr->content_length), |
207 base::Bind(&DriveUploader::StartUploadFileAfterGetFileSize, | 208 base::Bind(&DriveUploader::StartUploadFileAfterGetFileSize, |
208 weak_ptr_factory_.GetWeakPtr(), | 209 weak_ptr_factory_.GetWeakPtr(), |
209 base::Passed(&upload_file_info), | 210 base::Passed(&upload_file_info), |
210 start_initiate_upload_callback)); | 211 start_initiate_upload_callback)); |
211 return info_ptr->GetCancelCallback(); | 212 return info_ptr->GetCancelCallback(); |
212 } | 213 } |
213 | 214 |
214 void DriveUploader::StartUploadFileAfterGetFileSize( | 215 void DriveUploader::StartUploadFileAfterGetFileSize( |
215 scoped_ptr<UploadFileInfo> upload_file_info, | 216 scoped_ptr<UploadFileInfo> upload_file_info, |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 GDataErrorCode error) { | 400 GDataErrorCode error) { |
400 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 401 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
401 | 402 |
402 LOG(ERROR) << "Upload failed " << upload_file_info->DebugString(); | 403 LOG(ERROR) << "Upload failed " << upload_file_info->DebugString(); |
403 | 404 |
404 upload_file_info->completion_callback.Run( | 405 upload_file_info->completion_callback.Run( |
405 error, upload_file_info->upload_location, scoped_ptr<ResourceEntry>()); | 406 error, upload_file_info->upload_location, scoped_ptr<ResourceEntry>()); |
406 } | 407 } |
407 | 408 |
408 } // namespace drive | 409 } // namespace drive |
OLD | NEW |