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

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api.cc

Issue 11711003: Remove the DownloadItem::TogglePause() interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 12 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/extensions/api/downloads/downloads_api.h" 5 #include "chrome/browser/extensions/api/downloads/downloads_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cctype> 8 #include <cctype>
9 #include <iterator> 9 #include <iterator>
10 #include <set> 10 #include <set>
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 bool DownloadsPauseFunction::RunImpl() { 696 bool DownloadsPauseFunction::RunImpl() {
697 scoped_ptr<extensions::api::downloads::Pause::Params> params( 697 scoped_ptr<extensions::api::downloads::Pause::Params> params(
698 extensions::api::downloads::Pause::Params::Create(*args_)); 698 extensions::api::downloads::Pause::Params::Create(*args_));
699 EXTENSION_FUNCTION_VALIDATE(params.get()); 699 EXTENSION_FUNCTION_VALIDATE(params.get());
700 DownloadItem* download_item = GetDownloadIfInProgress( 700 DownloadItem* download_item = GetDownloadIfInProgress(
701 profile(), include_incognito(), params->download_id); 701 profile(), include_incognito(), params->download_id);
702 if (download_item == NULL) { 702 if (download_item == NULL) {
703 // This could be due to an invalid download ID, or it could be due to the 703 // This could be due to an invalid download ID, or it could be due to the
704 // download not being currently active. 704 // download not being currently active.
705 error_ = download_extension_errors::kInvalidOperationError; 705 error_ = download_extension_errors::kInvalidOperationError;
706 } else if (!download_item->IsPaused()) { 706 } else if (!download_item->IsPaused()) {
asanka 2013/01/02 16:44:50 Nit: Since we now have Pause() and Resume(), I don
Randy Smith (Not in Mondays) 2013/01/02 20:16:02 Done.
707 // If download_item->IsPaused() already then we treat it as a success. 707 // If download_item->IsPaused() already then we treat it as a success.
708 download_item->TogglePause(); 708 download_item->Pause();
709 } 709 }
710 if (error_.empty()) 710 if (error_.empty())
711 RecordApiFunctions(DOWNLOADS_FUNCTION_PAUSE); 711 RecordApiFunctions(DOWNLOADS_FUNCTION_PAUSE);
712 return error_.empty(); 712 return error_.empty();
713 } 713 }
714 714
715 DownloadsResumeFunction::DownloadsResumeFunction() {} 715 DownloadsResumeFunction::DownloadsResumeFunction() {}
716 DownloadsResumeFunction::~DownloadsResumeFunction() {} 716 DownloadsResumeFunction::~DownloadsResumeFunction() {}
717 717
718 bool DownloadsResumeFunction::RunImpl() { 718 bool DownloadsResumeFunction::RunImpl() {
719 scoped_ptr<extensions::api::downloads::Resume::Params> params( 719 scoped_ptr<extensions::api::downloads::Resume::Params> params(
720 extensions::api::downloads::Resume::Params::Create(*args_)); 720 extensions::api::downloads::Resume::Params::Create(*args_));
721 EXTENSION_FUNCTION_VALIDATE(params.get()); 721 EXTENSION_FUNCTION_VALIDATE(params.get());
722 DownloadItem* download_item = GetDownloadIfInProgress( 722 DownloadItem* download_item = GetDownloadIfInProgress(
723 profile(), include_incognito(), params->download_id); 723 profile(), include_incognito(), params->download_id);
724 if (download_item == NULL) { 724 if (download_item == NULL) {
725 // This could be due to an invalid download ID, or it could be due to the 725 // This could be due to an invalid download ID, or it could be due to the
726 // download not being currently active. 726 // download not being currently active.
727 error_ = download_extension_errors::kInvalidOperationError; 727 error_ = download_extension_errors::kInvalidOperationError;
728 } else if (download_item->IsPaused()) { 728 } else if (download_item->IsPaused()) {
729 // If !download_item->IsPaused() already, then we treat it as a success. 729 // If !download_item->IsPaused() already, then we treat it as a success.
730 download_item->TogglePause(); 730 download_item->Resume();
731 } 731 }
732 if (error_.empty()) 732 if (error_.empty())
733 RecordApiFunctions(DOWNLOADS_FUNCTION_RESUME); 733 RecordApiFunctions(DOWNLOADS_FUNCTION_RESUME);
734 return error_.empty(); 734 return error_.empty();
735 } 735 }
736 736
737 DownloadsCancelFunction::DownloadsCancelFunction() {} 737 DownloadsCancelFunction::DownloadsCancelFunction() {}
738 DownloadsCancelFunction::~DownloadsCancelFunction() {} 738 DownloadsCancelFunction::~DownloadsCancelFunction() {}
739 739
740 bool DownloadsCancelFunction::RunImpl() { 740 bool DownloadsCancelFunction::RunImpl() {
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 if (profile_->HasOffTheRecordProfile() && 1022 if (profile_->HasOffTheRecordProfile() &&
1023 !profile_->IsOffTheRecord()) { 1023 !profile_->IsOffTheRecord()) {
1024 DispatchEventInternal( 1024 DispatchEventInternal(
1025 profile_->GetOffTheRecordProfile(), 1025 profile_->GetOffTheRecordProfile(),
1026 event_name, 1026 event_name,
1027 json_args, 1027 json_args,
1028 scoped_ptr<base::ListValue>(args->DeepCopy())); 1028 scoped_ptr<base::ListValue>(args->DeepCopy()));
1029 } 1029 }
1030 DispatchEventInternal(profile_, event_name, json_args, args.Pass()); 1030 DispatchEventInternal(profile_, event_name, json_args, args.Pass());
1031 } 1031 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698