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

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

Issue 1890163004: extensions: Abstract out install delay strategy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for comments in #4 Created 4 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 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 iter != extensions->end(); 227 iter != extensions->end();
228 ++iter) { 228 ++iter) {
229 if (AppIsolationInfo::HasIsolatedStorage(iter->get())) { 229 if (AppIsolationInfo::HasIsolatedStorage(iter->get())) {
230 active_paths->insert( 230 active_paths->insert(
231 content::BrowserContext::GetStoragePartitionForSite( 231 content::BrowserContext::GetStoragePartitionForSite(
232 context_, util::GetSiteForExtensionId((*iter)->id(), context_)) 232 context_, util::GetSiteForExtensionId((*iter)->id(), context_))
233 ->GetPath()); 233 ->GetPath());
234 } 234 }
235 } 235 }
236 236
237 ExtensionService* service = 237 DCHECK(!installs_delayed_for_gc_);
238 ExtensionSystem::Get(context_)->extension_service(); 238 installs_delayed_for_gc_ = true;
239 service->OnGarbageCollectIsolatedStorageStart();
240 content::BrowserContext::GarbageCollectStoragePartitions( 239 content::BrowserContext::GarbageCollectStoragePartitions(
241 context_, std::move(active_paths), 240 context_, std::move(active_paths),
242 base::Bind(&ExtensionService::OnGarbageCollectIsolatedStorageFinished, 241 base::Bind(
243 service->AsWeakPtr())); 242 &ExtensionGarbageCollector::OnGarbageCollectIsolatedStorageFinished,
243 weak_factory_.GetWeakPtr()));
244 }
245
246 void ExtensionGarbageCollector::OnGarbageCollectIsolatedStorageFinished() {
247 DCHECK(installs_delayed_for_gc_);
248 installs_delayed_for_gc_ = false;
249
250 ExtensionSystem::Get(context_)
251 ->extension_service()
252 ->MaybeFinishDelayedInstallations();
244 } 253 }
245 254
246 void ExtensionGarbageCollector::OnBeginCrxInstall( 255 void ExtensionGarbageCollector::OnBeginCrxInstall(
247 const std::string& extension_id) { 256 const std::string& extension_id) {
248 crx_installs_in_progress_++; 257 crx_installs_in_progress_++;
249 } 258 }
250 259
251 void ExtensionGarbageCollector::OnFinishCrxInstall( 260 void ExtensionGarbageCollector::OnFinishCrxInstall(
252 const std::string& extension_id, 261 const std::string& extension_id,
253 bool success) { 262 bool success) {
254 crx_installs_in_progress_--; 263 crx_installs_in_progress_--;
255 if (crx_installs_in_progress_ < 0) { 264 if (crx_installs_in_progress_ < 0) {
256 // This can only happen if there is a mismatch in our begin/finish 265 // This can only happen if there is a mismatch in our begin/finish
257 // accounting. 266 // accounting.
258 NOTREACHED(); 267 NOTREACHED();
259 268
260 // Don't let the count go negative to avoid garbage collecting when 269 // Don't let the count go negative to avoid garbage collecting when
261 // an install is actually in progress. 270 // an install is actually in progress.
262 crx_installs_in_progress_ = 0; 271 crx_installs_in_progress_ = 0;
263 } 272 }
264 } 273 }
265 274
275 InstallGate::Action ExtensionGarbageCollector::ShouldDelay(
276 const Extension* extension,
277 bool install_immediately) {
278 return installs_delayed_for_gc_ ? DELAY : INSTALL;
279 }
280
266 } // namespace extensions 281 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698