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

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 2825963003: Rewrite base::Bind to base::BindOnce with base_bind_rewriters in //chrome/browser/extensions (Closed)
Patch Set: Created 3 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/extension_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 pending_extension_manager()->GetById(id); 563 pending_extension_manager()->GetById(id);
564 564
565 const Extension* extension = GetInstalledExtension(id); 565 const Extension* extension = GetInstalledExtension(id);
566 if (!pending_extension_info && !extension) { 566 if (!pending_extension_info && !extension) {
567 LOG(WARNING) << "Will not update extension " << id 567 LOG(WARNING) << "Will not update extension " << id
568 << " because it is not installed or pending"; 568 << " because it is not installed or pending";
569 // Delete extension_path since we're not creating a CrxInstaller 569 // Delete extension_path since we're not creating a CrxInstaller
570 // that would do it for us. 570 // that would do it for us.
571 if (file_ownership_passed && 571 if (file_ownership_passed &&
572 !GetFileTaskRunner()->PostTask( 572 !GetFileTaskRunner()->PostTask(
573 FROM_HERE, 573 FROM_HERE, base::BindOnce(&extensions::file_util::DeleteFile,
574 base::Bind(&extensions::file_util::DeleteFile, file.path, false))) 574 file.path, false)))
575 NOTREACHED(); 575 NOTREACHED();
576 576
577 return false; 577 return false;
578 } 578 }
579 579
580 scoped_refptr<CrxInstaller> installer(CrxInstaller::CreateSilent(this)); 580 scoped_refptr<CrxInstaller> installer(CrxInstaller::CreateSilent(this));
581 installer->set_expected_id(id); 581 installer->set_expected_id(id);
582 installer->set_expected_hash(file.expected_hash); 582 installer->set_expected_hash(file.expected_hash);
583 int creation_flags = Extension::NO_FLAGS; 583 int creation_flags = Extension::NO_FLAGS;
584 if (pending_extension_info) { 584 if (pending_extension_info) {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 // Unload before doing more cleanup to ensure that nothing is hanging on to 822 // Unload before doing more cleanup to ensure that nothing is hanging on to
823 // any of these resources. 823 // any of these resources.
824 UnloadExtension(extension->id(), UnloadedExtensionInfo::REASON_UNINSTALL); 824 UnloadExtension(extension->id(), UnloadedExtensionInfo::REASON_UNINSTALL);
825 if (registry_->blacklisted_extensions().Contains(extension->id())) 825 if (registry_->blacklisted_extensions().Contains(extension->id()))
826 registry_->RemoveBlacklisted(extension->id()); 826 registry_->RemoveBlacklisted(extension->id());
827 827
828 // Tell the backend to start deleting installed extensions on the file thread. 828 // Tell the backend to start deleting installed extensions on the file thread.
829 if (!Manifest::IsUnpackedLocation(extension->location())) { 829 if (!Manifest::IsUnpackedLocation(extension->location())) {
830 if (!GetFileTaskRunner()->PostTask( 830 if (!GetFileTaskRunner()->PostTask(
831 FROM_HERE, 831 FROM_HERE,
832 base::Bind(&ExtensionService::UninstallExtensionOnFileThread, 832 base::BindOnce(&ExtensionService::UninstallExtensionOnFileThread,
833 extension->id(), 833 extension->id(), profile_, install_directory_,
834 profile_, 834 extension->path())))
835 install_directory_,
836 extension->path())))
837 NOTREACHED(); 835 NOTREACHED();
838 } 836 }
839 837
840 extensions::DataDeleter::StartDeleting( 838 extensions::DataDeleter::StartDeleting(
841 profile_, extension.get(), deletion_done_callback); 839 profile_, extension.get(), deletion_done_callback);
842 840
843 UntrackTerminatedExtension(extension->id()); 841 UntrackTerminatedExtension(extension->id());
844 842
845 // Notify interested parties that we've uninstalled this extension. 843 // Notify interested parties that we've uninstalled this extension.
846 ExtensionRegistry::Get(profile_) 844 ExtensionRegistry::Get(profile_)
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 1805
1808 LOG(WARNING) << "ShouldAllowInstall() returned false for " 1806 LOG(WARNING) << "ShouldAllowInstall() returned false for "
1809 << id << " of type " << extension->GetType() 1807 << id << " of type " << extension->GetType()
1810 << " and update URL " 1808 << " and update URL "
1811 << extensions::ManifestURL::GetUpdateURL(extension).spec() 1809 << extensions::ManifestURL::GetUpdateURL(extension).spec()
1812 << "; not installing"; 1810 << "; not installing";
1813 1811
1814 // Delete the extension directory since we're not going to 1812 // Delete the extension directory since we're not going to
1815 // load it. 1813 // load it.
1816 if (!GetFileTaskRunner()->PostTask( 1814 if (!GetFileTaskRunner()->PostTask(
1817 FROM_HERE, 1815 FROM_HERE, base::BindOnce(&extensions::file_util::DeleteFile,
1818 base::Bind(&extensions::file_util::DeleteFile, 1816 extension->path(), true))) {
1819 extension->path(),
1820 true))) {
1821 NOTREACHED(); 1817 NOTREACHED();
1822 } 1818 }
1823 return; 1819 return;
1824 } 1820 }
1825 1821
1826 install_parameter = pending_extension_info->install_parameter(); 1822 install_parameter = pending_extension_info->install_parameter();
1827 pending_extension_manager()->Remove(id); 1823 pending_extension_manager()->Remove(id);
1828 } else { 1824 } else {
1829 // We explicitly want to re-enable an uninstalled external 1825 // We explicitly want to re-enable an uninstalled external
1830 // extension; if we're here, that means the user is manually 1826 // extension; if we're here, that means the user is manually
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
2208 // do. 2204 // do.
2209 if (!extensions_being_terminated_.insert(host->extension_id()).second) 2205 if (!extensions_being_terminated_.insert(host->extension_id()).second)
2210 break; 2206 break;
2211 2207
2212 // Mark the extension as terminated and Unload it. We want it to 2208 // Mark the extension as terminated and Unload it. We want it to
2213 // be in a consistent state: either fully working or not loaded 2209 // be in a consistent state: either fully working or not loaded
2214 // at all, but never half-crashed. We do it in a PostTask so 2210 // at all, but never half-crashed. We do it in a PostTask so
2215 // that other handlers of this notification will still have 2211 // that other handlers of this notification will still have
2216 // access to the Extension and ExtensionHost. 2212 // access to the Extension and ExtensionHost.
2217 base::ThreadTaskRunnerHandle::Get()->PostTask( 2213 base::ThreadTaskRunnerHandle::Get()->PostTask(
2218 FROM_HERE, base::Bind(&ExtensionService::TrackTerminatedExtension, 2214 FROM_HERE, base::BindOnce(&ExtensionService::TrackTerminatedExtension,
2219 AsWeakPtr(), host->extension()->id())); 2215 AsWeakPtr(), host->extension()->id()));
2220 break; 2216 break;
2221 } 2217 }
2222 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: { 2218 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: {
2223 content::RenderProcessHost* process = 2219 content::RenderProcessHost* process =
2224 content::Source<content::RenderProcessHost>(source).ptr(); 2220 content::Source<content::RenderProcessHost>(source).ptr();
2225 Profile* host_profile = 2221 Profile* host_profile =
2226 Profile::FromBrowserContext(process->GetBrowserContext()); 2222 Profile::FromBrowserContext(process->GetBrowserContext());
2227 if (!profile_->IsSameProfile(host_profile->GetOriginalProfile())) 2223 if (!profile_->IsSameProfile(host_profile->GetOriginalProfile()))
2228 break; 2224 break;
2229 2225
(...skipping 22 matching lines...) Expand all
2252 import_ids.insert((*import_it).extension_id); 2248 import_ids.insert((*import_it).extension_id);
2253 } 2249 }
2254 } 2250 }
2255 extension_ids.insert(import_ids.begin(), import_ids.end()); 2251 extension_ids.insert(import_ids.begin(), import_ids.end());
2256 2252
2257 for (std::set<std::string>::const_iterator it = extension_ids.begin(); 2253 for (std::set<std::string>::const_iterator it = extension_ids.begin();
2258 it != extension_ids.end(); ++it) { 2254 it != extension_ids.end(); ++it) {
2259 if (delayed_installs_.Contains(*it)) { 2255 if (delayed_installs_.Contains(*it)) {
2260 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 2256 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
2261 FROM_HERE, 2257 FROM_HERE,
2262 base::Bind(&ExtensionService::MaybeFinishDelayedInstallation, 2258 base::BindOnce(
2263 AsWeakPtr(), *it), 2259 &ExtensionService::MaybeFinishDelayedInstallation,
2260 AsWeakPtr(), *it),
2264 base::TimeDelta::FromSeconds(kUpdateIdleDelay)); 2261 base::TimeDelta::FromSeconds(kUpdateIdleDelay));
2265 } 2262 }
2266 } 2263 }
2267 } 2264 }
2268 2265
2269 process_map->RemoveAllFromProcess(process->GetID()); 2266 process_map->RemoveAllFromProcess(process->GetID());
2270 BrowserThread::PostTask( 2267 BrowserThread::PostTask(
2271 BrowserThread::IO, 2268 BrowserThread::IO, FROM_HERE,
2272 FROM_HERE, 2269 base::BindOnce(&extensions::InfoMap::UnregisterAllExtensionsInProcess,
2273 base::Bind(&extensions::InfoMap::UnregisterAllExtensionsInProcess, 2270 system_->info_map(), process->GetID()));
2274 system_->info_map(),
2275 process->GetID()));
2276 break; 2271 break;
2277 } 2272 }
2278 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: { 2273 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: {
2279 // Notify observers that chrome update is available. 2274 // Notify observers that chrome update is available.
2280 for (auto& observer : update_observers_) 2275 for (auto& observer : update_observers_)
2281 observer.OnChromeUpdateAvailable(); 2276 observer.OnChromeUpdateAvailable();
2282 break; 2277 break;
2283 } 2278 }
2284 case chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED: { 2279 case chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED: {
2285 OnProfileDestructionStarted(); 2280 OnProfileDestructionStarted();
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
2558 } 2553 }
2559 2554
2560 void ExtensionService::OnProfileDestructionStarted() { 2555 void ExtensionService::OnProfileDestructionStarted() {
2561 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); 2556 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2562 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); 2557 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2563 it != ids_to_unload.end(); 2558 it != ids_to_unload.end();
2564 ++it) { 2559 ++it) {
2565 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); 2560 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2566 } 2561 }
2567 } 2562 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_messages_apitest.cc ('k') | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698