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 file_mb = static_cast<int>( | |
627 (page_count_bytes * page_size_bytes) / (1024 * 1024)); | |
628 UMA_HISTOGRAM_MEMORY_MB("History.FaviconDatabaseSizeMB", file_mb); | |
Roger McFarlane (Chromium)
2015/03/25 18:20:18
KB?
beaudoin
2015/03/25 18:31:48
+1, MB has an overly large first bin.
| |
629 } | |
630 | |
631 // Count all icon files 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 "large" icon files referenced by the DB. | |
651 { | |
652 sql::Statement large_favicon_count( | |
653 db_.GetCachedStatement( | |
654 SQL_FROM_HERE, | |
655 "SELECT COUNT(*) FROM favicons WHERE icon_type > ?")); | |
beaudoin
2015/03/25 18:31:48
I think I'd prefer something like "width > 64" or
brettw
2015/03/25 19:38:53
Also, I think this allows you to delete the large
Roger McFarlane (Chromium)
2015/03/26 18:26:33
The schema doesn't quite allow for this, but perha
| |
656 large_favicon_count.BindInt64(0, favicon_base::FAVICON); | |
657 UMA_HISTOGRAM_COUNTS_10000( | |
658 "History.NumLargeFaviconsInDB", | |
659 large_favicon_count.Step() ? large_favicon_count.ColumnInt(0) : 0); | |
660 } | |
661 | |
662 // Count the subset of "large" bitmap resources cached in the DB. | |
663 { | |
664 sql::Statement large_bitmap_count( | |
665 db_.GetCachedStatement( | |
666 SQL_FROM_HERE, | |
667 "SELECT COUNT(*) FROM favicon_bitmaps " | |
668 "WHERE id IN (SELECT id FROM favicons WHERE icon_type > ?)")); | |
669 large_bitmap_count.BindInt64(0, favicon_base::FAVICON); | |
670 UMA_HISTOGRAM_COUNTS_10000( | |
671 "History.NumLargeFaviconBitmapsInDB", | |
672 large_bitmap_count.Step() ? large_bitmap_count.ColumnInt(0) : 0); | |
673 } | |
674 | |
675 UMA_HISTOGRAM_TIMES("History.FaviconDatabaseAdvancedMetricsTime", | |
676 base::TimeTicks::Now() - start_time); | |
621 } | 677 } |
622 | 678 |
623 void ThumbnailDatabase::BeginTransaction() { | 679 void ThumbnailDatabase::BeginTransaction() { |
624 db_.BeginTransaction(); | 680 db_.BeginTransaction(); |
625 } | 681 } |
626 | 682 |
627 void ThumbnailDatabase::CommitTransaction() { | 683 void ThumbnailDatabase::CommitTransaction() { |
628 db_.CommitTransaction(); | 684 db_.CommitTransaction(); |
629 } | 685 } |
630 | 686 |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1298 meta_table_.SetVersionNumber(7); | 1354 meta_table_.SetVersionNumber(7); |
1299 meta_table_.SetCompatibleVersionNumber(std::min(7, kCompatibleVersionNumber)); | 1355 meta_table_.SetCompatibleVersionNumber(std::min(7, kCompatibleVersionNumber)); |
1300 return true; | 1356 return true; |
1301 } | 1357 } |
1302 | 1358 |
1303 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { | 1359 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { |
1304 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); | 1360 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); |
1305 } | 1361 } |
1306 | 1362 |
1307 } // namespace history | 1363 } // namespace history |
OLD | NEW |