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

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: lint Created 8 years, 4 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 "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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698