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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
237 | 237 |
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::INTERRUPTED: | |
248 // Interrupted downloads can be resumed. Keep the Drive user data around | |
249 // so that it can be used when the download resumes. The download is truly | |
250 // done when it's complete, is cancelled or is removed. | |
251 break; | |
Randy Smith (Not in Mondays)
2013/05/15 19:00:18
How does this work over a browser restart? I.e. i
asanka
2013/05/23 20:30:37
On a browser restart, drive downloads get deleted
| |
252 | |
247 case DownloadItem::CANCELLED: | 253 case DownloadItem::CANCELLED: |
248 case DownloadItem::INTERRUPTED: | |
249 download->SetUserData(&kDrivePathKey, NULL); | 254 download->SetUserData(&kDrivePathKey, NULL); |
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, |
(...skipping 37 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 |