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

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: Created 7 years, 8 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 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 filename_change_.Run(determined_filename_, conflict_action); 678 filename_change_.Run(determined_filename_, conflict_action);
679 } 679 }
680 } 680 }
681 // Don't clear determiners_ immediately in case there's a second listener 681 // Don't clear determiners_ immediately in case there's a second listener
682 // for one of the extensions, so that DetermineFilename can return 682 // for one of the extensions, so that DetermineFilename can return
683 // kTooManyListenersError. After a few seconds, DetermineFilename will 683 // kTooManyListenersError. After a few seconds, DetermineFilename will
684 // return kInvalidOperationError instead of kTooManyListenersError so that 684 // return kInvalidOperationError instead of kTooManyListenersError so that
685 // determiners_ doesn't keep hogging memory. 685 // determiners_ doesn't keep hogging memory.
686 weak_ptr_factory_.reset( 686 weak_ptr_factory_.reset(
687 new base::WeakPtrFactory<ExtensionDownloadsEventRouterData>(this)); 687 new base::WeakPtrFactory<ExtensionDownloadsEventRouterData>(this));
688 MessageLoopForUI::current()->PostDelayedTask( 688 base::MessageLoopForUI::current()->PostDelayedTask(
689 FROM_HERE, 689 FROM_HERE,
690 base::Bind(&ExtensionDownloadsEventRouterData::ClearPendingDeterminers, 690 base::Bind(&ExtensionDownloadsEventRouterData::ClearPendingDeterminers,
691 weak_ptr_factory_->GetWeakPtr()), 691 weak_ptr_factory_->GetWeakPtr()),
692 base::TimeDelta::FromSeconds(30)); 692 base::TimeDelta::FromSeconds(30));
693 } 693 }
694 694
695 int updated_; 695 int updated_;
696 int changed_fired_; 696 int changed_fired_;
697 scoped_ptr<base::DictionaryValue> json_; 697 scoped_ptr<base::DictionaryValue> json_;
698 698
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 if (!download_item || !web_contents) { 1134 if (!download_item || !web_contents) {
1135 error_ = download_extension_errors::kInvalidOperationError; 1135 error_ = download_extension_errors::kInvalidOperationError;
1136 return false; 1136 return false;
1137 } 1137 }
1138 RecordApiFunctions(DOWNLOADS_FUNCTION_DRAG); 1138 RecordApiFunctions(DOWNLOADS_FUNCTION_DRAG);
1139 gfx::Image* icon = g_browser_process->icon_manager()->LookupIconFromFilepath( 1139 gfx::Image* icon = g_browser_process->icon_manager()->LookupIconFromFilepath(
1140 download_item->GetUserVerifiedFilePath(), IconLoader::NORMAL); 1140 download_item->GetUserVerifiedFilePath(), IconLoader::NORMAL);
1141 gfx::NativeView view = web_contents->GetView()->GetNativeView(); 1141 gfx::NativeView view = web_contents->GetView()->GetNativeView();
1142 { 1142 {
1143 // Enable nested tasks during DnD, while |DragDownload()| blocks. 1143 // Enable nested tasks during DnD, while |DragDownload()| blocks.
1144 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); 1144 base::MessageLoop::ScopedNestableTaskAllower allow(
1145 base::MessageLoop::current());
1145 download_util::DragDownload(download_item, icon, view); 1146 download_util::DragDownload(download_item, icon, view);
1146 } 1147 }
1147 return true; 1148 return true;
1148 } 1149 }
1149 1150
1150 DownloadsGetFileIconFunction::DownloadsGetFileIconFunction() 1151 DownloadsGetFileIconFunction::DownloadsGetFileIconFunction()
1151 : icon_extractor_(new DownloadFileIconExtractorImpl()) { 1152 : icon_extractor_(new DownloadFileIconExtractorImpl()) {
1152 } 1153 }
1153 1154
1154 DownloadsGetFileIconFunction::~DownloadsGetFileIconFunction() {} 1155 DownloadsGetFileIconFunction::~DownloadsGetFileIconFunction() {}
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 DownloadsNotificationSource notification_source; 1496 DownloadsNotificationSource notification_source;
1496 notification_source.event_name = event_name; 1497 notification_source.event_name = event_name;
1497 notification_source.profile = profile_; 1498 notification_source.profile = profile_;
1498 content::Source<DownloadsNotificationSource> content_source( 1499 content::Source<DownloadsNotificationSource> content_source(
1499 &notification_source); 1500 &notification_source);
1500 content::NotificationService::current()->Notify( 1501 content::NotificationService::current()->Notify(
1501 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, 1502 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT,
1502 content_source, 1503 content_source,
1503 content::Details<std::string>(&json_args)); 1504 content::Details<std::string>(&json_args));
1504 } 1505 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698