OLD | NEW |
---|---|
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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
606 if (status == sql::INIT_OK) | 606 if (status == sql::INIT_OK) |
607 return status; | 607 return status; |
608 | 608 |
609 meta_table_.Reset(); | 609 meta_table_.Reset(); |
610 db_.Close(); | 610 db_.Close(); |
611 } | 611 } |
612 return status; | 612 return status; |
613 } | 613 } |
614 | 614 |
615 void ThumbnailDatabase::ComputeDatabaseMetrics() { | 615 void ThumbnailDatabase::ComputeDatabaseMetrics() { |
616 sql::Statement favicon_count( | 616 base::TimeTicks start_time = base::TimeTicks::Now(); |
617 db_.GetCachedStatement(SQL_FROM_HERE, "SELECT COUNT(*) FROM favicons")); | 617 |
618 UMA_HISTOGRAM_COUNTS_10000( | 618 // Calculate the size of the favicon database. |
619 "History.NumFaviconsInDB", | 619 { |
620 favicon_count.Step() ? favicon_count.ColumnInt(0) : 0); | 620 sql::Statement page_count( |
621 db_.GetCachedStatement(SQL_FROM_HERE, "PRAGMA page_count")); | |
622 int64 page_count_bytes = page_count.Step() ? page_count.ColumnInt64(0) : 0; | |
623 sql::Statement page_size( | |
624 db_.GetCachedStatement(SQL_FROM_HERE, "PRAGMA page_size")); | |
625 int64 page_size_bytes = page_size.Step() ? page_size.ColumnInt64(0) : 0; | |
626 int size_mb = static_cast<int>( | |
627 (page_count_bytes * page_size_bytes) / (1024 * 1024)); | |
628 UMA_HISTOGRAM_MEMORY_MB("History.FaviconDatabaseSizeMB", size_mb); | |
629 } | |
630 | |
631 // Count all icon URLs referenced by the DB. | |
632 { | |
633 sql::Statement favicon_count( | |
634 db_.GetCachedStatement(SQL_FROM_HERE, "SELECT COUNT(*) FROM favicons")); | |
635 UMA_HISTOGRAM_COUNTS_10000( | |
636 "History.NumFaviconsInDB", | |
637 favicon_count.Step() ? favicon_count.ColumnInt(0) : 0); | |
638 } | |
639 | |
640 // Count all bitmap resources cached in the DB. | |
641 { | |
642 sql::Statement bitmap_count( | |
643 db_.GetCachedStatement( | |
644 SQL_FROM_HERE, "SELECT COUNT(*) FROM favicon_bitmaps")); | |
645 UMA_HISTOGRAM_COUNTS_10000( | |
646 "History.NumFaviconBitmapsInDB", | |
647 bitmap_count.Step() ? bitmap_count.ColumnInt(0) : 0); | |
648 } | |
649 | |
650 // Count the subset of "touch" icon URLs referenced by the DB. | |
pkotwicz
2015/03/30 19:25:19
How about: "Count "touch" icon URLs referenced in
Roger McFarlane (Chromium)
2015/03/31 14:33:10
Done.
| |
651 { | |
652 sql::Statement touch_icon_count( | |
653 db_.GetCachedStatement( | |
654 SQL_FROM_HERE, | |
655 "SELECT COUNT(*) FROM favicons WHERE icon_type in (?, ?)")); | |
pkotwicz
2015/03/30 19:25:19
Nit: 'in' -> 'IN'
Roger McFarlane (Chromium)
2015/03/31 14:33:10
Done.
| |
656 touch_icon_count.BindInt64(0, favicon_base::TOUCH_ICON); | |
657 touch_icon_count.BindInt64(0, favicon_base::TOUCH_PRECOMPOSED_ICON); | |
658 UMA_HISTOGRAM_COUNTS_10000( | |
659 "History.NumTouchIconsInDB", | |
660 touch_icon_count.Step() ? touch_icon_count.ColumnInt(0) : 0); | |
661 } | |
662 | |
663 // Count the subset of "large" bitmap resources cached in the DB. | |
pkotwicz
2015/03/30 19:25:19
How about: "Count "large" bitmap resources cached
Roger McFarlane (Chromium)
2015/03/31 14:33:10
Done.
| |
664 { | |
665 sql::Statement large_bitmap_count( | |
666 db_.GetCachedStatement( | |
667 SQL_FROM_HERE, | |
668 "SELECT COUNT(*) FROM favicon_bitmaps WHERE width >= 64")); | |
669 UMA_HISTOGRAM_COUNTS_10000( | |
670 "History.NumLargeFaviconBitmapsInDB", | |
671 large_bitmap_count.Step() ? large_bitmap_count.ColumnInt(0) : 0); | |
672 } | |
673 | |
674 // Count all icon mappings maintained by the DB. | |
675 { | |
676 sql::Statement mapping_count( | |
677 db_.GetCachedStatement( | |
678 SQL_FROM_HERE, "SELECT COUNT(*) FROM icon_mapping")); | |
679 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
680 "History.NumFaviconMappingsInDB", | |
681 (mapping_count.Step() ? mapping_count.ColumnInt(0) : 0), | |
682 1, 100000, 100); | |
683 } | |
684 | |
685 UMA_HISTOGRAM_TIMES("History.FaviconDatabaseAdvancedMetricsTime", | |
686 base::TimeTicks::Now() - start_time); | |
621 } | 687 } |
622 | 688 |
623 void ThumbnailDatabase::BeginTransaction() { | 689 void ThumbnailDatabase::BeginTransaction() { |
624 db_.BeginTransaction(); | 690 db_.BeginTransaction(); |
625 } | 691 } |
626 | 692 |
627 void ThumbnailDatabase::CommitTransaction() { | 693 void ThumbnailDatabase::CommitTransaction() { |
628 db_.CommitTransaction(); | 694 db_.CommitTransaction(); |
629 } | 695 } |
630 | 696 |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1298 meta_table_.SetVersionNumber(7); | 1364 meta_table_.SetVersionNumber(7); |
1299 meta_table_.SetCompatibleVersionNumber(std::min(7, kCompatibleVersionNumber)); | 1365 meta_table_.SetCompatibleVersionNumber(std::min(7, kCompatibleVersionNumber)); |
1300 return true; | 1366 return true; |
1301 } | 1367 } |
1302 | 1368 |
1303 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { | 1369 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { |
1304 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); | 1370 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); |
1305 } | 1371 } |
1306 | 1372 |
1307 } // namespace history | 1373 } // namespace history |
OLD | NEW |