Chromium Code Reviews| 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 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. We define | |
| 651 // "large" icon files all types other than INVALID_ICON and FAVICON, for | |
| 652 // which we usually store only small (16x16 or 32x32) bitmaps by default. | |
|
pkotwicz
2015/03/27 15:45:25
Can you rename the UMA metric to be "History.NumTo
Roger McFarlane (Chromium)
2015/03/30 17:35:48
Done.
| |
| 653 { | |
| 654 sql::Statement large_favicon_count( | |
| 655 db_.GetCachedStatement( | |
| 656 SQL_FROM_HERE, | |
| 657 "SELECT COUNT(*) FROM favicons WHERE icon_type not in (?, ?)")); | |
| 658 large_favicon_count.BindInt64(0, favicon_base::INVALID_ICON); | |
| 659 large_favicon_count.BindInt64(0, favicon_base::FAVICON); | |
| 660 UMA_HISTOGRAM_COUNTS_10000( | |
| 661 "History.NumLargeFaviconsInDB", | |
| 662 large_favicon_count.Step() ? large_favicon_count.ColumnInt(0) : 0); | |
| 663 } | |
| 664 | |
| 665 // Count the subset of "large" bitmap resources cached in the DB. | |
| 666 { | |
| 667 sql::Statement large_bitmap_count( | |
| 668 db_.GetCachedStatement( | |
| 669 SQL_FROM_HERE, | |
| 670 "SELECT COUNT(*) FROM favicon_bitmaps WHERE width >= 64")); | |
| 671 UMA_HISTOGRAM_COUNTS_10000( | |
| 672 "History.NumLargeFaviconBitmapsInDB", | |
| 673 large_bitmap_count.Step() ? large_bitmap_count.ColumnInt(0) : 0); | |
| 674 } | |
| 675 | |
| 676 // Count all icon mappings maintained by the DB. | |
| 677 { | |
| 678 sql::Statement mapping_count( | |
| 679 db_.GetCachedStatement( | |
| 680 SQL_FROM_HERE, "SELECT COUNT(*) FROM icon_mapping")); | |
| 681 UMA_HISTOGRAM_COUNTS_10000( | |
|
pkotwicz
2015/03/27 15:45:25
I checked the "icon_mapping" table for the instanc
Roger McFarlane (Chromium)
2015/03/30 17:35:48
Done.
| |
| 682 "History.NumFaviconsMappingsInDB", | |
|
pkotwicz
2015/03/27 15:45:25
Nit: History.NumFaviconsMappingsInDB -> History.Nu
Roger McFarlane (Chromium)
2015/03/30 17:35:48
Done.
| |
| 683 mapping_count.Step() ? mapping_count.ColumnInt(0) : 0); | |
| 684 } | |
| 685 | |
| 686 UMA_HISTOGRAM_TIMES("History.FaviconDatabaseAdvancedMetricsTime", | |
| 687 base::TimeTicks::Now() - start_time); | |
| 621 } | 688 } |
| 622 | 689 |
| 623 void ThumbnailDatabase::BeginTransaction() { | 690 void ThumbnailDatabase::BeginTransaction() { |
| 624 db_.BeginTransaction(); | 691 db_.BeginTransaction(); |
| 625 } | 692 } |
| 626 | 693 |
| 627 void ThumbnailDatabase::CommitTransaction() { | 694 void ThumbnailDatabase::CommitTransaction() { |
| 628 db_.CommitTransaction(); | 695 db_.CommitTransaction(); |
| 629 } | 696 } |
| 630 | 697 |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1298 meta_table_.SetVersionNumber(7); | 1365 meta_table_.SetVersionNumber(7); |
| 1299 meta_table_.SetCompatibleVersionNumber(std::min(7, kCompatibleVersionNumber)); | 1366 meta_table_.SetCompatibleVersionNumber(std::min(7, kCompatibleVersionNumber)); |
| 1300 return true; | 1367 return true; |
| 1301 } | 1368 } |
| 1302 | 1369 |
| 1303 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { | 1370 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { |
| 1304 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); | 1371 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); |
| 1305 } | 1372 } |
| 1306 | 1373 |
| 1307 } // namespace history | 1374 } // namespace history |
| OLD | NEW |