| 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/chromeos/drive/download_handler.h" | 5 #include "chrome/browser/chromeos/drive/download_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/supports_user_data.h" | 9 #include "base/supports_user_data.h" |
| 10 #include "chrome/browser/chromeos/drive/drive.pb.h" | 10 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 switch (download->GetState()) { | 238 switch (download->GetState()) { |
| 239 case DownloadItem::IN_PROGRESS: | 239 case DownloadItem::IN_PROGRESS: |
| 240 break; | 240 break; |
| 241 | 241 |
| 242 case DownloadItem::COMPLETE: | 242 case DownloadItem::COMPLETE: |
| 243 UploadDownloadItem(download); | 243 UploadDownloadItem(download); |
| 244 data->set_complete(); | 244 data->set_complete(); |
| 245 break; | 245 break; |
| 246 | 246 |
| 247 case DownloadItem::CANCELLED: | 247 case DownloadItem::CANCELLED: |
| 248 download->SetUserData(&kDrivePathKey, NULL); |
| 249 break; |
| 250 |
| 248 case DownloadItem::INTERRUPTED: | 251 case DownloadItem::INTERRUPTED: |
| 249 download->SetUserData(&kDrivePathKey, NULL); | 252 // Interrupted downloads can be resumed. Keep the Drive user data around |
| 253 // so that it can be used when the download resumes. The download is truly |
| 254 // done when it's complete, is cancelled or is removed. |
| 250 break; | 255 break; |
| 251 | 256 |
| 252 default: | 257 default: |
| 253 NOTREACHED(); | 258 NOTREACHED(); |
| 254 } | 259 } |
| 255 } | 260 } |
| 256 | 261 |
| 257 void DownloadHandler::OnEntryFound( | 262 void DownloadHandler::OnEntryFound( |
| 258 const base::FilePath& drive_dir_path, | 263 const base::FilePath& drive_dir_path, |
| 259 const SubstituteDriveDownloadPathCallback& callback, | 264 const SubstituteDriveDownloadPathCallback& callback, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 } | 301 } |
| 297 | 302 |
| 298 void DownloadHandler::UploadDownloadItem(DownloadItem* download) { | 303 void DownloadHandler::UploadDownloadItem(DownloadItem* download) { |
| 299 DCHECK(download->IsComplete()); | 304 DCHECK(download->IsComplete()); |
| 300 file_write_helper_->PrepareWritableFileAndRun( | 305 file_write_helper_->PrepareWritableFileAndRun( |
| 301 util::ExtractDrivePath(GetTargetPath(download)), | 306 util::ExtractDrivePath(GetTargetPath(download)), |
| 302 base::Bind(&MoveDownloadedFile, download->GetTargetFilePath())); | 307 base::Bind(&MoveDownloadedFile, download->GetTargetFilePath())); |
| 303 } | 308 } |
| 304 | 309 |
| 305 } // namespace drive | 310 } // namespace drive |
| OLD | NEW |