| 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 "google_apis/drive/base_requests.h" | 5 #include "google_apis/drive/base_requests.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 base::FilePath* local_file_path, | 977 base::FilePath* local_file_path, |
| 978 GetContentCallback* get_content_callback) { | 978 GetContentCallback* get_content_callback) { |
| 979 // Configure so that the downloaded content is saved to |output_file_path_|. | 979 // Configure so that the downloaded content is saved to |output_file_path_|. |
| 980 *local_file_path = output_file_path_; | 980 *local_file_path = output_file_path_; |
| 981 *get_content_callback = get_content_callback_; | 981 *get_content_callback = get_content_callback_; |
| 982 } | 982 } |
| 983 | 983 |
| 984 void DownloadFileRequestBase::OnURLFetchDownloadProgress( | 984 void DownloadFileRequestBase::OnURLFetchDownloadProgress( |
| 985 const URLFetcher* source, | 985 const URLFetcher* source, |
| 986 int64_t current, | 986 int64_t current, |
| 987 int64_t total) { | 987 int64_t total, |
| 988 int64_t current_network_bytes) { |
| 988 if (!progress_callback_.is_null()) | 989 if (!progress_callback_.is_null()) |
| 989 progress_callback_.Run(current, total); | 990 progress_callback_.Run(current, total); |
| 990 } | 991 } |
| 991 | 992 |
| 992 void DownloadFileRequestBase::ProcessURLFetchResults(const URLFetcher* source) { | 993 void DownloadFileRequestBase::ProcessURLFetchResults(const URLFetcher* source) { |
| 993 DriveApiErrorCode code = GetErrorCode(); | 994 DriveApiErrorCode code = GetErrorCode(); |
| 994 | 995 |
| 995 // Take over the ownership of the the downloaded temp file. | 996 // Take over the ownership of the the downloaded temp file. |
| 996 base::FilePath temp_file; | 997 base::FilePath temp_file; |
| 997 if (code == HTTP_SUCCESS) { | 998 if (code == HTTP_SUCCESS) { |
| 998 response_writer()->DisownFile(); | 999 response_writer()->DisownFile(); |
| 999 temp_file = output_file_path_; | 1000 temp_file = output_file_path_; |
| 1000 } | 1001 } |
| 1001 | 1002 |
| 1002 download_action_callback_.Run(code, temp_file); | 1003 download_action_callback_.Run(code, temp_file); |
| 1003 OnProcessURLFetchResultsComplete(); | 1004 OnProcessURLFetchResultsComplete(); |
| 1004 } | 1005 } |
| 1005 | 1006 |
| 1006 void DownloadFileRequestBase::RunCallbackOnPrematureFailure( | 1007 void DownloadFileRequestBase::RunCallbackOnPrematureFailure( |
| 1007 DriveApiErrorCode code) { | 1008 DriveApiErrorCode code) { |
| 1008 download_action_callback_.Run(code, base::FilePath()); | 1009 download_action_callback_.Run(code, base::FilePath()); |
| 1009 } | 1010 } |
| 1010 | 1011 |
| 1011 } // namespace google_apis | 1012 } // namespace google_apis |
| OLD | NEW |