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

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: merge 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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 break; 361 break;
362 362
363 case DownloadItem::COMPLETE: 363 case DownloadItem::COMPLETE:
364 UploadDownloadItem(download); 364 UploadDownloadItem(download);
365 MoveFileToGDataCache(download); 365 MoveFileToGDataCache(download);
366 RemovePendingDownload(download); 366 RemovePendingDownload(download);
367 break; 367 break;
368 368
369 // TODO(achuith): Stop the pending upload and delete the file. 369 // TODO(achuith): Stop the pending upload and delete the file.
370 case DownloadItem::CANCELLED: 370 case DownloadItem::CANCELLED:
371 case DownloadItem::REMOVING:
372 case DownloadItem::INTERRUPTED: 371 case DownloadItem::INTERRUPTED:
373 RemovePendingDownload(download); 372 RemovePendingDownload(download);
374 break; 373 break;
375 374
376 default: 375 default:
377 NOTREACHED(); 376 NOTREACHED();
378 } 377 }
379 378
380 DVLOG(1) << "Number of pending downloads=" << pending_downloads_.size(); 379 DVLOG(1) << "Number of pending downloads=" << pending_downloads_.size();
381 } 380 }
382 381
382 void GDataDownloadObserver::OnDownloadDestroyed(DownloadItem* download) {
383 RemovePendingDownload(download);
384 }
385
383 void GDataDownloadObserver::AddPendingDownload(DownloadItem* download) { 386 void GDataDownloadObserver::AddPendingDownload(DownloadItem* download) {
384 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 387 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
385 388
386 // Add ourself as an observer of this download if we've never seen it before. 389 // Add ourself as an observer of this download if we've never seen it before.
387 if (pending_downloads_.count(download->GetId()) == 0) { 390 if (pending_downloads_.count(download->GetId()) == 0) {
388 pending_downloads_[download->GetId()] = download; 391 pending_downloads_[download->GetId()] = download;
389 download->AddObserver(this); 392 download->AddObserver(this);
390 DVLOG(1) << "new download total bytes=" << download->GetTotalBytes() 393 DVLOG(1) << "new download total bytes=" << download->GetTotalBytes()
391 << ", full path=" << download->GetFullPath().value() 394 << ", full path=" << download->GetFullPath().value()
392 << ", mime type=" << download->GetMimeType(); 395 << ", mime type=" << download->GetMimeType();
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 file_system_->AddUploadedFile(UPLOAD_NEW_FILE, 535 file_system_->AddUploadedFile(UPLOAD_NEW_FILE,
533 data->virtual_dir_path(), 536 data->virtual_dir_path(),
534 entry, 537 entry,
535 download->GetTargetFilePath(), 538 download->GetTargetFilePath(),
536 GDataCache::FILE_OPERATION_MOVE, 539 GDataCache::FILE_OPERATION_MOVE,
537 base::Bind(&base::DeletePointer<DocumentEntry>, 540 base::Bind(&base::DeletePointer<DocumentEntry>,
538 entry)); 541 entry));
539 } 542 }
540 543
541 } // namespace gdata 544 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698