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

Side by Side Diff: components/history/core/browser/thumbnail_database.cc

Issue 1032763002: Add favicon database histograms to UMA. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + fix owner email Created 5 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
« 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 "components/history/core/browser/thumbnail_database.h" 5 #include "components/history/core/browser/thumbnail_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 if (status == sql::INIT_OK) 612 if (status == sql::INIT_OK)
613 return status; 613 return status;
614 614
615 meta_table_.Reset(); 615 meta_table_.Reset();
616 db_.Close(); 616 db_.Close();
617 } 617 }
618 return status; 618 return status;
619 } 619 }
620 620
621 void ThumbnailDatabase::ComputeDatabaseMetrics() { 621 void ThumbnailDatabase::ComputeDatabaseMetrics() {
622 sql::Statement favicon_count( 622 base::TimeTicks start_time = base::TimeTicks::Now();
623 db_.GetCachedStatement(SQL_FROM_HERE, "SELECT COUNT(*) FROM favicons")); 623
624 UMA_HISTOGRAM_COUNTS_10000( 624 // Calculate the size of the favicon database.
625 "History.NumFaviconsInDB", 625 {
626 favicon_count.Step() ? favicon_count.ColumnInt(0) : 0); 626 sql::Statement page_count(
627 db_.GetCachedStatement(SQL_FROM_HERE, "PRAGMA page_count"));
628 int64 page_count_bytes = page_count.Step() ? page_count.ColumnInt64(0) : 0;
629 sql::Statement page_size(
630 db_.GetCachedStatement(SQL_FROM_HERE, "PRAGMA page_size"));
631 int64 page_size_bytes = page_size.Step() ? page_size.ColumnInt64(0) : 0;
632 int size_mb = static_cast<int>(
633 (page_count_bytes * page_size_bytes) / (1024 * 1024));
634 UMA_HISTOGRAM_MEMORY_MB("History.FaviconDatabaseSizeMB", size_mb);
635 }
636
637 // Count all icon URLs referenced by the DB.
638 {
639 sql::Statement favicon_count(
640 db_.GetCachedStatement(SQL_FROM_HERE, "SELECT COUNT(*) FROM favicons"));
641 UMA_HISTOGRAM_COUNTS_10000(
642 "History.NumFaviconsInDB",
643 favicon_count.Step() ? favicon_count.ColumnInt(0) : 0);
644 }
645
646 // Count all bitmap resources cached in the DB.
647 {
648 sql::Statement bitmap_count(
649 db_.GetCachedStatement(
650 SQL_FROM_HERE, "SELECT COUNT(*) FROM favicon_bitmaps"));
651 UMA_HISTOGRAM_COUNTS_10000(
652 "History.NumFaviconBitmapsInDB",
653 bitmap_count.Step() ? bitmap_count.ColumnInt(0) : 0);
654 }
655
656 // Count "touch" icon URLs referenced by the DB.
657 {
658 sql::Statement touch_icon_count(
659 db_.GetCachedStatement(
660 SQL_FROM_HERE,
661 "SELECT COUNT(*) FROM favicons WHERE icon_type IN (?, ?)"));
662 touch_icon_count.BindInt64(0, favicon_base::TOUCH_ICON);
663 touch_icon_count.BindInt64(0, favicon_base::TOUCH_PRECOMPOSED_ICON);
664 UMA_HISTOGRAM_COUNTS_10000(
665 "History.NumTouchIconsInDB",
666 touch_icon_count.Step() ? touch_icon_count.ColumnInt(0) : 0);
667 }
668
669 // Count "large" bitmap resources cached in the DB.
670 {
671 sql::Statement large_bitmap_count(
672 db_.GetCachedStatement(
673 SQL_FROM_HERE,
674 "SELECT COUNT(*) FROM favicon_bitmaps WHERE width >= 64"));
675 UMA_HISTOGRAM_COUNTS_10000(
676 "History.NumLargeFaviconBitmapsInDB",
677 large_bitmap_count.Step() ? large_bitmap_count.ColumnInt(0) : 0);
678 }
679
680 // Count all icon mappings maintained by the DB.
681 {
682 sql::Statement mapping_count(
683 db_.GetCachedStatement(
684 SQL_FROM_HERE, "SELECT COUNT(*) FROM icon_mapping"));
685 UMA_HISTOGRAM_CUSTOM_COUNTS(
686 "History.NumFaviconMappingsInDB",
687 (mapping_count.Step() ? mapping_count.ColumnInt(0) : 0),
688 1, 100000, 100);
689 }
690
691 UMA_HISTOGRAM_TIMES("History.FaviconDatabaseAdvancedMetricsTime",
692 base::TimeTicks::Now() - start_time);
627 } 693 }
628 694
629 void ThumbnailDatabase::BeginTransaction() { 695 void ThumbnailDatabase::BeginTransaction() {
630 db_.BeginTransaction(); 696 db_.BeginTransaction();
631 } 697 }
632 698
633 void ThumbnailDatabase::CommitTransaction() { 699 void ThumbnailDatabase::CommitTransaction() {
634 db_.CommitTransaction(); 700 db_.CommitTransaction();
635 } 701 }
636 702
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 meta_table_.SetVersionNumber(8); 1405 meta_table_.SetVersionNumber(8);
1340 meta_table_.SetCompatibleVersionNumber(std::min(8, kCompatibleVersionNumber)); 1406 meta_table_.SetCompatibleVersionNumber(std::min(8, kCompatibleVersionNumber));
1341 return true; 1407 return true;
1342 } 1408 }
1343 1409
1344 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { 1410 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() {
1345 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); 1411 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons");
1346 } 1412 }
1347 1413
1348 } // namespace history 1414 } // namespace history
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