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

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

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 filename_change_.Run(determined_filename_, conflict_action); 674 filename_change_.Run(determined_filename_, conflict_action);
675 } 675 }
676 } 676 }
677 // Don't clear determiners_ immediately in case there's a second listener 677 // Don't clear determiners_ immediately in case there's a second listener
678 // for one of the extensions, so that DetermineFilename can return 678 // for one of the extensions, so that DetermineFilename can return
679 // kTooManyListenersError. After a few seconds, DetermineFilename will 679 // kTooManyListenersError. After a few seconds, DetermineFilename will
680 // return kInvalidOperationError instead of kTooManyListenersError so that 680 // return kInvalidOperationError instead of kTooManyListenersError so that
681 // determiners_ doesn't keep hogging memory. 681 // determiners_ doesn't keep hogging memory.
682 weak_ptr_factory_.reset( 682 weak_ptr_factory_.reset(
683 new base::WeakPtrFactory<ExtensionDownloadsEventRouterData>(this)); 683 new base::WeakPtrFactory<ExtensionDownloadsEventRouterData>(this));
684 MessageLoopForUI::current()->PostDelayedTask( 684 base::MessageLoopForUI::current()->PostDelayedTask(
685 FROM_HERE, 685 FROM_HERE,
686 base::Bind(&ExtensionDownloadsEventRouterData::ClearPendingDeterminers, 686 base::Bind(&ExtensionDownloadsEventRouterData::ClearPendingDeterminers,
687 weak_ptr_factory_->GetWeakPtr()), 687 weak_ptr_factory_->GetWeakPtr()),
688 base::TimeDelta::FromSeconds(30)); 688 base::TimeDelta::FromSeconds(30));
689 } 689 }
690 690
691 int updated_; 691 int updated_;
692 int changed_fired_; 692 int changed_fired_;
693 scoped_ptr<base::DictionaryValue> json_; 693 scoped_ptr<base::DictionaryValue> json_;
694 694
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 if (!download_item || !web_contents) { 1131 if (!download_item || !web_contents) {
1132 error_ = download_extension_errors::kInvalidOperationError; 1132 error_ = download_extension_errors::kInvalidOperationError;
1133 return false; 1133 return false;
1134 } 1134 }
1135 RecordApiFunctions(DOWNLOADS_FUNCTION_DRAG); 1135 RecordApiFunctions(DOWNLOADS_FUNCTION_DRAG);
1136 gfx::Image* icon = g_browser_process->icon_manager()->LookupIconFromFilepath( 1136 gfx::Image* icon = g_browser_process->icon_manager()->LookupIconFromFilepath(
1137 download_item->GetTargetFilePath(), IconLoader::NORMAL); 1137 download_item->GetTargetFilePath(), IconLoader::NORMAL);
1138 gfx::NativeView view = web_contents->GetView()->GetNativeView(); 1138 gfx::NativeView view = web_contents->GetView()->GetNativeView();
1139 { 1139 {
1140 // Enable nested tasks during DnD, while |DragDownload()| blocks. 1140 // Enable nested tasks during DnD, while |DragDownload()| blocks.
1141 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); 1141 base::MessageLoop::ScopedNestableTaskAllower allow(
1142 base::MessageLoop::current());
1142 download_util::DragDownload(download_item, icon, view); 1143 download_util::DragDownload(download_item, icon, view);
1143 } 1144 }
1144 return true; 1145 return true;
1145 } 1146 }
1146 1147
1147 DownloadsGetFileIconFunction::DownloadsGetFileIconFunction() 1148 DownloadsGetFileIconFunction::DownloadsGetFileIconFunction()
1148 : icon_extractor_(new DownloadFileIconExtractorImpl()) { 1149 : icon_extractor_(new DownloadFileIconExtractorImpl()) {
1149 } 1150 }
1150 1151
1151 DownloadsGetFileIconFunction::~DownloadsGetFileIconFunction() {} 1152 DownloadsGetFileIconFunction::~DownloadsGetFileIconFunction() {}
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 DownloadsNotificationSource notification_source; 1501 DownloadsNotificationSource notification_source;
1501 notification_source.event_name = event_name; 1502 notification_source.event_name = event_name;
1502 notification_source.profile = profile_; 1503 notification_source.profile = profile_;
1503 content::Source<DownloadsNotificationSource> content_source( 1504 content::Source<DownloadsNotificationSource> content_source(
1504 &notification_source); 1505 &notification_source);
1505 content::NotificationService::current()->Notify( 1506 content::NotificationService::current()->Notify(
1506 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, 1507 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT,
1507 content_source, 1508 content_source,
1508 content::Details<std::string>(&json_args)); 1509 content::Details<std::string>(&json_args));
1509 } 1510 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698