| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_garbage_collector.h" | 5 #include "chrome/browser/extensions/extension_garbage_collector.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 if (extension_prefs->pref_service()->ReadOnly()) | 173 if (extension_prefs->pref_service()->ReadOnly()) |
| 174 return; | 174 return; |
| 175 | 175 |
| 176 if (crx_installs_in_progress_ > 0) { | 176 if (crx_installs_in_progress_ > 0) { |
| 177 // Don't garbage collect while there are installations in progress, | 177 // Don't garbage collect while there are installations in progress, |
| 178 // which may be using the temporary installation directory. Try to garbage | 178 // which may be using the temporary installation directory. Try to garbage |
| 179 // collect again later. | 179 // collect again later. |
| 180 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 180 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 181 FROM_HERE, | 181 FROM_HERE, |
| 182 base::Bind(&ExtensionGarbageCollector::GarbageCollectExtensions, | 182 base::BindOnce(&ExtensionGarbageCollector::GarbageCollectExtensions, |
| 183 weak_factory_.GetWeakPtr()), | 183 weak_factory_.GetWeakPtr()), |
| 184 base::TimeDelta::FromSeconds(kGarbageCollectRetryDelayInSeconds)); | 184 base::TimeDelta::FromSeconds(kGarbageCollectRetryDelayInSeconds)); |
| 185 return; | 185 return; |
| 186 } | 186 } |
| 187 | 187 |
| 188 std::unique_ptr<ExtensionPrefs::ExtensionsInfo> info( | 188 std::unique_ptr<ExtensionPrefs::ExtensionsInfo> info( |
| 189 extension_prefs->GetInstalledExtensionsInfo()); | 189 extension_prefs->GetInstalledExtensionsInfo()); |
| 190 std::multimap<std::string, base::FilePath> extension_paths; | 190 std::multimap<std::string, base::FilePath> extension_paths; |
| 191 for (size_t i = 0; i < info->size(); ++i) { | 191 for (size_t i = 0; i < info->size(); ++i) { |
| 192 extension_paths.insert( | 192 extension_paths.insert( |
| 193 std::make_pair(info->at(i)->extension_id, info->at(i)->extension_path)); | 193 std::make_pair(info->at(i)->extension_id, info->at(i)->extension_path)); |
| 194 } | 194 } |
| 195 | 195 |
| 196 info = extension_prefs->GetAllDelayedInstallInfo(); | 196 info = extension_prefs->GetAllDelayedInstallInfo(); |
| 197 for (size_t i = 0; i < info->size(); ++i) { | 197 for (size_t i = 0; i < info->size(); ++i) { |
| 198 extension_paths.insert( | 198 extension_paths.insert( |
| 199 std::make_pair(info->at(i)->extension_id, info->at(i)->extension_path)); | 199 std::make_pair(info->at(i)->extension_id, info->at(i)->extension_path)); |
| 200 } | 200 } |
| 201 | 201 |
| 202 ExtensionService* service = | 202 ExtensionService* service = |
| 203 ExtensionSystem::Get(context_)->extension_service(); | 203 ExtensionSystem::Get(context_)->extension_service(); |
| 204 if (!service->GetFileTaskRunner()->PostTask( | 204 if (!service->GetFileTaskRunner()->PostTask( |
| 205 FROM_HERE, | 205 FROM_HERE, |
| 206 base::Bind(&GarbageCollectExtensionsOnFileThread, | 206 base::BindOnce(&GarbageCollectExtensionsOnFileThread, |
| 207 service->install_directory(), | 207 service->install_directory(), extension_paths))) { |
| 208 extension_paths))) { | |
| 209 NOTREACHED(); | 208 NOTREACHED(); |
| 210 } | 209 } |
| 211 } | 210 } |
| 212 | 211 |
| 213 void ExtensionGarbageCollector::GarbageCollectIsolatedStorageIfNeeded() { | 212 void ExtensionGarbageCollector::GarbageCollectIsolatedStorageIfNeeded() { |
| 214 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 213 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 215 | 214 |
| 216 ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(context_); | 215 ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(context_); |
| 217 DCHECK(extension_prefs); | 216 DCHECK(extension_prefs); |
| 218 if (!extension_prefs->NeedsStorageGarbageCollection()) | 217 if (!extension_prefs->NeedsStorageGarbageCollection()) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 } | 271 } |
| 273 } | 272 } |
| 274 | 273 |
| 275 InstallGate::Action ExtensionGarbageCollector::ShouldDelay( | 274 InstallGate::Action ExtensionGarbageCollector::ShouldDelay( |
| 276 const Extension* extension, | 275 const Extension* extension, |
| 277 bool install_immediately) { | 276 bool install_immediately) { |
| 278 return installs_delayed_for_gc_ ? DELAY : INSTALL; | 277 return installs_delayed_for_gc_ ? DELAY : INSTALL; |
| 279 } | 278 } |
| 280 | 279 |
| 281 } // namespace extensions | 280 } // namespace extensions |
| OLD | NEW |