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 "chrome/browser/chromeos/gdata/gdata.pb.h" | 9 #include "chrome/browser/chromeos/gdata/gdata.pb.h" |
10 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h" | 10 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h" |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 UploadDownloadItem(download); | 351 UploadDownloadItem(download); |
352 break; | 352 break; |
353 | 353 |
354 case DownloadItem::COMPLETE: | 354 case DownloadItem::COMPLETE: |
355 UploadDownloadItem(download); | 355 UploadDownloadItem(download); |
356 RemovePendingDownload(download); | 356 RemovePendingDownload(download); |
357 break; | 357 break; |
358 | 358 |
359 // TODO(achuith): Stop the pending upload and delete the file. | 359 // TODO(achuith): Stop the pending upload and delete the file. |
360 case DownloadItem::CANCELLED: | 360 case DownloadItem::CANCELLED: |
361 case DownloadItem::REMOVING: | |
362 case DownloadItem::INTERRUPTED: | 361 case DownloadItem::INTERRUPTED: |
363 RemovePendingDownload(download); | 362 RemovePendingDownload(download); |
364 break; | 363 break; |
365 | 364 |
366 default: | 365 default: |
367 NOTREACHED(); | 366 NOTREACHED(); |
368 } | 367 } |
369 DVLOG(1) << "Number of pending downloads=" << pending_downloads_.size(); | 368 DVLOG(1) << "Number of pending downloads=" << pending_downloads_.size(); |
370 } | 369 } |
371 | 370 |
| 371 void GDataDownloadObserver::OnDownloadDestructed(DownloadItem* download) { |
| 372 RemovePendingDownload(download); |
| 373 } |
| 374 |
372 void GDataDownloadObserver::AddPendingDownload(DownloadItem* download) { | 375 void GDataDownloadObserver::AddPendingDownload(DownloadItem* download) { |
373 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 376 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
374 | 377 |
375 // Add ourself as an observer of this download if we've never seen it before. | 378 // Add ourself as an observer of this download if we've never seen it before. |
376 if (pending_downloads_.count(download->GetId()) == 0) { | 379 if (pending_downloads_.count(download->GetId()) == 0) { |
377 pending_downloads_[download->GetId()] = download; | 380 pending_downloads_[download->GetId()] = download; |
378 download->AddObserver(this); | 381 download->AddObserver(this); |
379 DVLOG(1) << "new download total bytes=" << download->GetTotalBytes() | 382 DVLOG(1) << "new download total bytes=" << download->GetTotalBytes() |
380 << ", full path=" << download->GetFullPath().value() | 383 << ", full path=" << download->GetFullPath().value() |
381 << ", mime type=" << download->GetMimeType(); | 384 << ", mime type=" << download->GetMimeType(); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 return; | 483 return; |
481 } | 484 } |
482 DVLOG(1) << "Completing upload for download ID " << download_id; | 485 DVLOG(1) << "Completing upload for download ID " << download_id; |
483 DownloadItem* download_item = iter->second; | 486 DownloadItem* download_item = iter->second; |
484 UploadingExternalData* upload_data = GetUploadingExternalData(download_item); | 487 UploadingExternalData* upload_data = GetUploadingExternalData(download_item); |
485 DCHECK(upload_data); | 488 DCHECK(upload_data); |
486 upload_data->CompleteDownload(); | 489 upload_data->CompleteDownload(); |
487 } | 490 } |
488 | 491 |
489 } // namespace gdata | 492 } // namespace gdata |
OLD | NEW |