| 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/gdata/gdata_download_observer.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.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/gdata/gdata.pb.h" | 10 #include "chrome/browser/chromeos/gdata/gdata.pb.h" |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 break; | 357 break; |
| 358 | 358 |
| 359 case DownloadItem::COMPLETE: | 359 case DownloadItem::COMPLETE: |
| 360 UploadDownloadItem(download); | 360 UploadDownloadItem(download); |
| 361 MoveFileToGDataCache(download); | 361 MoveFileToGDataCache(download); |
| 362 RemovePendingDownload(download); | 362 RemovePendingDownload(download); |
| 363 break; | 363 break; |
| 364 | 364 |
| 365 // TODO(achuith): Stop the pending upload and delete the file. | 365 // TODO(achuith): Stop the pending upload and delete the file. |
| 366 case DownloadItem::CANCELLED: | 366 case DownloadItem::CANCELLED: |
| 367 case DownloadItem::REMOVING: | |
| 368 case DownloadItem::INTERRUPTED: | 367 case DownloadItem::INTERRUPTED: |
| 369 RemovePendingDownload(download); | 368 RemovePendingDownload(download); |
| 370 break; | 369 break; |
| 371 | 370 |
| 372 default: | 371 default: |
| 373 NOTREACHED(); | 372 NOTREACHED(); |
| 374 } | 373 } |
| 375 | 374 |
| 376 DVLOG(1) << "Number of pending downloads=" << pending_downloads_.size(); | 375 DVLOG(1) << "Number of pending downloads=" << pending_downloads_.size(); |
| 377 } | 376 } |
| 378 | 377 |
| 378 void GDataDownloadObserver::OnDownloadDestroyed(DownloadItem* download) { |
| 379 RemovePendingDownload(download); |
| 380 } |
| 381 |
| 379 void GDataDownloadObserver::AddPendingDownload(DownloadItem* download) { | 382 void GDataDownloadObserver::AddPendingDownload(DownloadItem* download) { |
| 380 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 383 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 381 | 384 |
| 382 // Add ourself as an observer of this download if we've never seen it before. | 385 // Add ourself as an observer of this download if we've never seen it before. |
| 383 if (pending_downloads_.count(download->GetId()) == 0) { | 386 if (pending_downloads_.count(download->GetId()) == 0) { |
| 384 pending_downloads_[download->GetId()] = download; | 387 pending_downloads_[download->GetId()] = download; |
| 385 download->AddObserver(this); | 388 download->AddObserver(this); |
| 386 DVLOG(1) << "new download total bytes=" << download->GetTotalBytes() | 389 DVLOG(1) << "new download total bytes=" << download->GetTotalBytes() |
| 387 << ", full path=" << download->GetFullPath().value() | 390 << ", full path=" << download->GetFullPath().value() |
| 388 << ", mime type=" << download->GetMimeType(); | 391 << ", mime type=" << download->GetMimeType(); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 // use the final target path when the download item is in COMPLETE state. | 574 // use the final target path when the download item is in COMPLETE state. |
| 572 file_system_->AddUploadedFile(UPLOAD_NEW_FILE, | 575 file_system_->AddUploadedFile(UPLOAD_NEW_FILE, |
| 573 upload_data->virtual_dir_path(), | 576 upload_data->virtual_dir_path(), |
| 574 entry.Pass(), | 577 entry.Pass(), |
| 575 download->GetTargetFilePath(), | 578 download->GetTargetFilePath(), |
| 576 GDataCache::FILE_OPERATION_MOVE, | 579 GDataCache::FILE_OPERATION_MOVE, |
| 577 base::Bind(&base::DoNothing)); | 580 base::Bind(&base::DoNothing)); |
| 578 } | 581 } |
| 579 | 582 |
| 580 } // namespace gdata | 583 } // namespace gdata |
| OLD | NEW |