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

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

Issue 2073523003: Add tagged histogram with reasons of purging the dom storage databases (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re-arrange ifs and add histogram names. Created 4 years, 6 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 | tools/metrics/histograms/histograms.xml » ('j') | 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 <inttypes.h> 7 #include <inttypes.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 return; 433 return;
434 434
435 DOMStorageNamespace::UsageStatistics initial_stats = 435 DOMStorageNamespace::UsageStatistics initial_stats =
436 GetTotalNamespaceStatistics(namespaces_); 436 GetTotalNamespaceStatistics(namespaces_);
437 437
438 // Track the total localStorage cache size. 438 // Track the total localStorage cache size.
439 UMA_HISTOGRAM_CUSTOM_COUNTS("LocalStorage.BrowserLocalStorageCacheSizeInKB", 439 UMA_HISTOGRAM_CUSTOM_COUNTS("LocalStorage.BrowserLocalStorageCacheSizeInKB",
440 initial_stats.total_cache_size / 1024, 1, 100000, 440 initial_stats.total_cache_size / 1024, 1, 100000,
441 50); 441 50);
442 442
443 const char* purge_reason = nullptr;
443 if (purge_option == PURGE_IF_NEEDED) { 444 if (purge_option == PURGE_IF_NEEDED) {
444 // Purging is done based on the cache sizes without including the database 445 // Purging is done based on the cache sizes without including the database
445 // size since it can be expensive trying to estimate the sqlite usage for 446 // size since it can be expensive trying to estimate the sqlite usage for
446 // all databases. For low end devices purge all inactive areas. 447 // all databases. For low end devices purge all inactive areas.
447 bool should_purge = 448 if (!initial_stats.inactive_area_count)
448 initial_stats.inactive_area_count && 449 return;
449 (is_low_end_device_ || initial_stats.total_cache_size > kMaxCacheSize || 450
450 initial_stats.total_area_count > kMaxStorageAreaCount); 451 if (initial_stats.total_cache_size > kMaxCacheSize)
451 if (!should_purge) 452 purge_reason = "SizeLimitExceeded";
453 else if (initial_stats.total_area_count > kMaxStorageAreaCount)
454 purge_reason = "AreaCountLimitExceeded";
455 else if (is_low_end_device_)
456 purge_reason = "InactiveOnLowEndDevice";
457 if (!purge_reason)
452 return; 458 return;
453 459
454 purge_option = PURGE_UNOPENED; 460 purge_option = PURGE_UNOPENED;
455 } 461 }
456 462
457 bool aggressively = purge_option == PURGE_AGGRESSIVE; 463 bool aggressively = purge_option == PURGE_AGGRESSIVE;
458 for (const auto& it : namespaces_) 464 for (const auto& it : namespaces_)
459 it.second->PurgeMemory(aggressively); 465 it.second->PurgeMemory(aggressively);
460 466
461 // Track the size of cache purged. 467 // Track the size of cache purged.
462 UMA_HISTOGRAM_CUSTOM_COUNTS( 468 if (!purge_reason) {
463 "LocalStorage.BrowserLocalStorageCachePurgedInKB", 469 if (purge_option == PURGE_AGGRESSIVE)
470 purge_reason = "AggressivePurgeTriggered";
471 else
472 purge_reason = "ModeratePurgeTriggered";
473 }
474 size_t purged_size_kib =
464 (initial_stats.total_cache_size - 475 (initial_stats.total_cache_size -
465 GetTotalNamespaceStatistics(namespaces_).total_cache_size) / 476 GetTotalNamespaceStatistics(namespaces_).total_cache_size) /
466 1024, 477 1024;
467 1, 100000, 50); 478 std::string full_histogram_name =
479 std::string("LocalStorage.BrowserLocalStorageCachePurgedInKB.") +
480 purge_reason;
481 base::HistogramBase* histogram = base::Histogram::FactoryGet(
482 full_histogram_name, 1, 100000, 50,
483 base::HistogramBase::kUmaTargetedHistogramFlag);
484 if (histogram)
485 histogram->Add(purged_size_kib);
486 UMA_HISTOGRAM_CUSTOM_COUNTS("LocalStorage.BrowserLocalStorageCachePurgedInKB",
487 purged_size_kib, 1, 100000, 50);
468 } 488 }
469 489
470 bool DOMStorageContextImpl::OnMemoryDump( 490 bool DOMStorageContextImpl::OnMemoryDump(
471 const base::trace_event::MemoryDumpArgs& args, 491 const base::trace_event::MemoryDumpArgs& args,
472 base::trace_event::ProcessMemoryDump* pmd) { 492 base::trace_event::ProcessMemoryDump* pmd) {
473 if (session_storage_database_) 493 if (session_storage_database_)
474 session_storage_database_->OnMemoryDump(pmd); 494 session_storage_database_->OnMemoryDump(pmd);
475 if (args.level_of_detail == 495 if (args.level_of_detail ==
476 base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND) { 496 base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND) {
477 DOMStorageNamespace::UsageStatistics total_stats = 497 DOMStorageNamespace::UsageStatistics total_stats =
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 if (!deletable_persistent_namespace_ids_.empty()) { 579 if (!deletable_persistent_namespace_ids_.empty()) {
560 task_runner_->PostDelayedTask( 580 task_runner_->PostDelayedTask(
561 FROM_HERE, base::Bind( 581 FROM_HERE, base::Bind(
562 &DOMStorageContextImpl::DeleteNextUnusedNamespace, 582 &DOMStorageContextImpl::DeleteNextUnusedNamespace,
563 this), 583 this),
564 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds)); 584 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds));
565 } 585 }
566 } 586 }
567 587
568 } // namespace content 588 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698