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

Side by Side Diff: content/browser/dom_storage/dom_storage_context_impl.cc

Issue 2015473002: Fix purging logic for dom_storage caches (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/dom_storage/dom_storage_context_impl.h" 5 #include "content/browser/dom_storage/dom_storage_context_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 // Track the total localStorage cache size. 436 // Track the total localStorage cache size.
437 UMA_HISTOGRAM_CUSTOM_COUNTS("LocalStorage.BrowserLocalStorageCacheSizeInKB", 437 UMA_HISTOGRAM_CUSTOM_COUNTS("LocalStorage.BrowserLocalStorageCacheSizeInKB",
438 initial_stats.total_cache_size / 1024, 1, 100000, 438 initial_stats.total_cache_size / 1024, 1, 100000,
439 50); 439 50);
440 440
441 if (purge_option == PURGE_IF_NEEDED) { 441 if (purge_option == PURGE_IF_NEEDED) {
442 // Purging is done based on the cache sizes without including the database 442 // Purging is done based on the cache sizes without including the database
443 // size since it can be expensive trying to estimate the sqlite usage for 443 // size since it can be expensive trying to estimate the sqlite usage for
444 // all databases. For low end devices purge all inactive areas. 444 // all databases. For low end devices purge all inactive areas.
445 bool should_purge = 445 bool should_purge =
446 (is_low_end_device_ && initial_stats.inactive_area_count) || 446 initial_stats.inactive_area_count &&
447 initial_stats.total_cache_size > kMaxCacheSize || 447 (is_low_end_device_ || initial_stats.total_cache_size > kMaxCacheSize ||
448 initial_stats.total_area_count > kMaxStorageAreaCount; 448 initial_stats.total_area_count > kMaxStorageAreaCount);
449 if (!should_purge) 449 if (!should_purge)
450 return; 450 return;
451 451
452 purge_option = PURGE_UNOPENED; 452 purge_option = PURGE_UNOPENED;
453 } 453 }
454 454
455 bool aggressively = purge_option == PURGE_AGGRESSIVE; 455 bool aggressively = purge_option == PURGE_AGGRESSIVE;
456 for (const auto& it : namespaces_) 456 for (const auto& it : namespaces_)
457 it.second->PurgeMemory(aggressively); 457 it.second->PurgeMemory(aggressively);
458 458
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 if (!deletable_persistent_namespace_ids_.empty()) { 539 if (!deletable_persistent_namespace_ids_.empty()) {
540 task_runner_->PostDelayedTask( 540 task_runner_->PostDelayedTask(
541 FROM_HERE, base::Bind( 541 FROM_HERE, base::Bind(
542 &DOMStorageContextImpl::DeleteNextUnusedNamespace, 542 &DOMStorageContextImpl::DeleteNextUnusedNamespace,
543 this), 543 this),
544 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds)); 544 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds));
545 } 545 }
546 } 546 }
547 547
548 } // namespace content 548 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698