Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(793)

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_download_observer.cc

Issue 10704026: Reland DownloadItem::Observer::OnDownloadDestroyed() replaces DownloadItem::REMOVING (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698