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

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

Issue 10694106: Added support for multiple parameters to Extension API callbacks. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Review fixes. 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
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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 BrowserThread::UI, FROM_HERE, 537 BrowserThread::UI, FROM_HERE,
538 base::Bind(&DownloadsDownloadFunction::OnStarted, this, 538 base::Bind(&DownloadsDownloadFunction::OnStarted, this,
539 DownloadId::Invalid(), error)); 539 DownloadId::Invalid(), error));
540 } 540 }
541 } 541 }
542 542
543 void DownloadsDownloadFunction::OnStarted(DownloadId dl_id, net::Error error) { 543 void DownloadsDownloadFunction::OnStarted(DownloadId dl_id, net::Error error) {
544 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 544 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
545 VLOG(1) << __FUNCTION__ << " " << dl_id << " " << error; 545 VLOG(1) << __FUNCTION__ << " " << dl_id << " " << error;
546 if (dl_id.local() >= 0) { 546 if (dl_id.local() >= 0) {
547 result_.reset(base::Value::CreateIntegerValue(dl_id.local())); 547 SetSingleResult(base::Value::CreateIntegerValue(dl_id.local()));
548 } else { 548 } else {
549 error_ = net::ErrorToString(error); 549 error_ = net::ErrorToString(error);
550 } 550 }
551 SendResponse(error_.empty()); 551 SendResponse(error_.empty());
552 } 552 }
553 553
554 DownloadsSearchFunction::DownloadsSearchFunction() 554 DownloadsSearchFunction::DownloadsSearchFunction()
555 : SyncDownloadsFunction(DOWNLOADS_FUNCTION_SEARCH), 555 : SyncDownloadsFunction(DOWNLOADS_FUNCTION_SEARCH),
556 query_(new DownloadQuery()), 556 query_(new DownloadQuery()),
557 get_id_(0), 557 get_id_(0),
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 incognito_manager->GetAllDownloads( 670 incognito_manager->GetAllDownloads(
671 FilePath(FILE_PATH_LITERAL("")), &all_items); 671 FilePath(FILE_PATH_LITERAL("")), &all_items);
672 } 672 }
673 query_->Search(all_items.begin(), all_items.end(), &cpp_results); 673 query_->Search(all_items.begin(), all_items.end(), &cpp_results);
674 base::ListValue* json_results = new base::ListValue(); 674 base::ListValue* json_results = new base::ListValue();
675 for (DownloadManager::DownloadVector::const_iterator it = cpp_results.begin(); 675 for (DownloadManager::DownloadVector::const_iterator it = cpp_results.begin();
676 it != cpp_results.end(); ++it) { 676 it != cpp_results.end(); ++it) {
677 scoped_ptr<base::DictionaryValue> item(DownloadItemToJSON(*it)); 677 scoped_ptr<base::DictionaryValue> item(DownloadItemToJSON(*it));
678 json_results->Append(item.release()); 678 json_results->Append(item.release());
679 } 679 }
680 result_.reset(json_results); 680 SetSingleResult(json_results);
681 return true; 681 return true;
682 } 682 }
683 683
684 DownloadsPauseFunction::DownloadsPauseFunction() 684 DownloadsPauseFunction::DownloadsPauseFunction()
685 : SyncDownloadsFunction(DOWNLOADS_FUNCTION_PAUSE), 685 : SyncDownloadsFunction(DOWNLOADS_FUNCTION_PAUSE),
686 download_id_(DownloadId::Invalid().local()) { 686 download_id_(DownloadId::Invalid().local()) {
687 } 687 }
688 688
689 DownloadsPauseFunction::~DownloadsPauseFunction() {} 689 DownloadsPauseFunction::~DownloadsPauseFunction() {}
690 690
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 path_, IconLoaderSizeFromPixelSize(icon_size_), 904 path_, IconLoaderSizeFromPixelSize(icon_size_),
905 base::Bind(&DownloadsGetFileIconFunction::OnIconURLExtracted, this))); 905 base::Bind(&DownloadsGetFileIconFunction::OnIconURLExtracted, this)));
906 return true; 906 return true;
907 } 907 }
908 908
909 void DownloadsGetFileIconFunction::OnIconURLExtracted(const std::string& url) { 909 void DownloadsGetFileIconFunction::OnIconURLExtracted(const std::string& url) {
910 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 910 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
911 if (url.empty()) 911 if (url.empty())
912 error_ = download_extension_errors::kIconNotFoundError; 912 error_ = download_extension_errors::kIconNotFoundError;
913 else 913 else
914 result_.reset(base::Value::CreateStringValue(url)); 914 SetSingleResult(base::Value::CreateStringValue(url));
915 SendResponse(error_.empty()); 915 SendResponse(error_.empty());
916 } 916 }
917 917
918 ExtensionDownloadsEventRouter::ExtensionDownloadsEventRouter( 918 ExtensionDownloadsEventRouter::ExtensionDownloadsEventRouter(
919 Profile* profile, 919 Profile* profile,
920 DownloadManager* manager) 920 DownloadManager* manager)
921 : profile_(profile), 921 : profile_(profile),
922 manager_(manager) { 922 manager_(manager) {
923 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 923 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
924 DCHECK(profile_); 924 DCHECK(profile_);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 extensions::EventFilteringInfo()); 1094 extensions::EventFilteringInfo());
1095 1095
1096 DownloadsNotificationSource notification_source; 1096 DownloadsNotificationSource notification_source;
1097 notification_source.event_name = event_name; 1097 notification_source.event_name = event_name;
1098 notification_source.profile = profile_; 1098 notification_source.profile = profile_;
1099 content::NotificationService::current()->Notify( 1099 content::NotificationService::current()->Notify(
1100 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, 1100 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT,
1101 content::Source<DownloadsNotificationSource>(&notification_source), 1101 content::Source<DownloadsNotificationSource>(&notification_source),
1102 content::Details<std::string>(&json_args)); 1102 content::Details<std::string>(&json_args));
1103 } 1103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698