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 "chrome/browser/history/thumbnail_database.h" | 5 #include "chrome/browser/history/thumbnail_database.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 | 73 |
| 74 | 74 |
| 75 | 75 |
| 76 static void FillIconMapping(const sql::Statement& statement, | 76 static void FillIconMapping(const sql::Statement& statement, |
| 77 const GURL& page_url, | 77 const GURL& page_url, |
| 78 history::IconMapping* icon_mapping) { | 78 history::IconMapping* icon_mapping) { |
| 79 icon_mapping->mapping_id = statement.ColumnInt64(0); | 79 icon_mapping->mapping_id = statement.ColumnInt64(0); |
| 80 icon_mapping->icon_id = statement.ColumnInt64(1); | 80 icon_mapping->icon_id = statement.ColumnInt64(1); |
| 81 icon_mapping->icon_type = | 81 icon_mapping->icon_type = |
| 82 static_cast<history::IconType>(statement.ColumnInt(2)); | 82 static_cast<history::IconType>(statement.ColumnInt(2)); |
| 83 icon_mapping->icon_url = GURL(statement.ColumnString(3)); | |
| 83 icon_mapping->page_url = page_url; | 84 icon_mapping->page_url = page_url; |
| 84 } | 85 } |
| 85 | 86 |
| 86 namespace history { | 87 namespace history { |
| 87 | 88 |
| 88 // Version number of the database. | 89 // Version number of the database. |
| 89 static const int kCurrentVersionNumber = 6; | 90 static const int kCurrentVersionNumber = 6; |
| 90 static const int kCompatibleVersionNumber = 6; | 91 static const int kCompatibleVersionNumber = 6; |
| 91 | 92 |
| 92 // Use 90 quality (out of 100) which is pretty high, because we're very | 93 // Use 90 quality (out of 100) which is pretty high, because we're very |
| 93 // sensitive to artifacts for these small sized, highly detailed images. | 94 // sensitive to artifacts for these small sized, highly detailed images. |
| 94 static const int kImageQuality = 90; | 95 static const int kImageQuality = 90; |
| 95 | 96 |
| 96 ThumbnailDatabase::IconMappingEnumerator::IconMappingEnumerator() { | 97 ThumbnailDatabase::IconMappingEnumerator::IconMappingEnumerator() { |
| 97 } | 98 } |
| 98 | 99 |
| 99 ThumbnailDatabase::IconMappingEnumerator::~IconMappingEnumerator() { | 100 ThumbnailDatabase::IconMappingEnumerator::~IconMappingEnumerator() { |
| 100 } | 101 } |
| 101 | 102 |
| 102 bool ThumbnailDatabase::IconMappingEnumerator::GetNextIconMapping( | 103 bool ThumbnailDatabase::IconMappingEnumerator::GetNextIconMapping( |
| 103 IconMapping* icon_mapping) { | 104 IconMapping* icon_mapping) { |
| 104 if (!statement_.Step()) | 105 if (!statement_.Step()) |
| 105 return false; | 106 return false; |
| 106 FillIconMapping(statement_, GURL(statement_.ColumnString(3)), icon_mapping); | 107 FillIconMapping(statement_, GURL(statement_.ColumnString(4)), icon_mapping); |
| 107 return true; | 108 return true; |
| 108 } | 109 } |
| 109 | 110 |
| 110 ThumbnailDatabase::ThumbnailDatabase() | 111 ThumbnailDatabase::ThumbnailDatabase() |
| 111 : history_publisher_(NULL), | 112 : history_publisher_(NULL), |
| 112 use_top_sites_(false) { | 113 use_top_sites_(false) { |
| 113 } | 114 } |
| 114 | 115 |
| 115 sql::InitStatus ThumbnailDatabase::CantUpgradeToVersion(int cur_version) { | 116 sql::InitStatus ThumbnailDatabase::CantUpgradeToVersion(int cur_version) { |
| 116 LOG(WARNING) << "Unable to update to thumbnail database to version " << | 117 LOG(WARNING) << "Unable to update to thumbnail database to version " << |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 double current_boring_score = select_statement.ColumnDouble(0); | 441 double current_boring_score = select_statement.ColumnDouble(0); |
| 441 bool current_clipping = select_statement.ColumnBool(1); | 442 bool current_clipping = select_statement.ColumnBool(1); |
| 442 bool current_at_top = select_statement.ColumnBool(2); | 443 bool current_at_top = select_statement.ColumnBool(2); |
| 443 base::Time last_updated = | 444 base::Time last_updated = |
| 444 base::Time::FromTimeT(select_statement.ColumnInt64(3)); | 445 base::Time::FromTimeT(select_statement.ColumnInt64(3)); |
| 445 *score = ThumbnailScore(current_boring_score, current_clipping, | 446 *score = ThumbnailScore(current_boring_score, current_clipping, |
| 446 current_at_top, last_updated); | 447 current_at_top, last_updated); |
| 447 return true; | 448 return true; |
| 448 } | 449 } |
| 449 | 450 |
| 451 bool ThumbnailDatabase::GetFaviconBitmapIDSizeListing( | |
| 452 FaviconID icon_id, | |
| 453 std::vector<FaviconBitmapIDSize>* bitmap_id_size_listing) { | |
| 454 DCHECK(icon_id); | |
| 455 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | |
| 456 "SELECT id, width, height FROM favicon_bitmaps WHERE icon_id=?")); | |
| 457 statement.BindInt64(0, icon_id); | |
| 458 | |
| 459 while (statement.Step()) { | |
| 460 FaviconBitmapIDSize bitmap_id_size; | |
| 461 bitmap_id_size.bitmap_id = statement.ColumnInt(0); | |
| 462 bitmap_id_size.pixel_size = gfx::Size(statement.ColumnInt(1), | |
| 463 statement.ColumnInt(2)); | |
| 464 bitmap_id_size_listing->push_back(bitmap_id_size); | |
| 465 } | |
| 466 return !bitmap_id_size_listing->empty(); | |
|
sky
2012/08/21 20:16:56
In this one you return whether non-empty, but not
| |
| 467 } | |
| 468 | |
| 450 bool ThumbnailDatabase::GetFaviconBitmaps( | 469 bool ThumbnailDatabase::GetFaviconBitmaps( |
| 451 FaviconID icon_id, | 470 FaviconID icon_id, |
| 452 std::vector<FaviconBitmap>* favicon_bitmaps) { | 471 std::vector<FaviconBitmap>* favicon_bitmaps) { |
| 453 DCHECK(icon_id); | 472 DCHECK(icon_id); |
| 454 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 473 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
| 455 "SELECT id, last_updated, image_data, width, height FROM favicon_bitmaps " | 474 "SELECT id, last_updated, image_data, width, height FROM favicon_bitmaps " |
| 456 "WHERE icon_id=?")); | 475 "WHERE icon_id=?")); |
| 457 statement.BindInt64(0, icon_id); | 476 statement.BindInt64(0, icon_id); |
| 458 | 477 |
| 459 bool result = false; | 478 bool result = false; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 497 } | 516 } |
| 498 statement.BindInt64(2, time.ToTimeT()); | 517 statement.BindInt64(2, time.ToTimeT()); |
| 499 statement.BindInt(3, pixel_size.width()); | 518 statement.BindInt(3, pixel_size.width()); |
| 500 statement.BindInt(4, pixel_size.height()); | 519 statement.BindInt(4, pixel_size.height()); |
| 501 | 520 |
| 502 if (!statement.Run()) | 521 if (!statement.Run()) |
| 503 return 0; | 522 return 0; |
| 504 return db_.GetLastInsertRowId(); | 523 return db_.GetLastInsertRowId(); |
| 505 } | 524 } |
| 506 | 525 |
| 507 bool ThumbnailDatabase::DeleteFaviconBitmapsForFavicon(FaviconID icon_id) { | 526 bool ThumbnailDatabase::SetFaviconBitmap( |
| 527 FaviconBitmapID bitmap_id, | |
| 528 scoped_refptr<base::RefCountedMemory> icon_data, | |
|
sky
2012/08/21 20:16:56
Shouldn't this take the size too?
pkotwicz
2012/09/04 16:18:36
In my opinion a favicon bitmap is uniquely identif
| |
| 529 base::Time time) { | |
| 530 DCHECK(bitmap_id); | |
| 508 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 531 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
| 509 "DELETE FROM favicon_bitmaps WHERE icon_id=?")); | 532 "UPDATE favicon_bitmaps SET image_data=?, last_updated=? WHERE id=?")); |
| 510 statement.BindInt64(0, icon_id); | 533 if (icon_data.get() && icon_data->size()) { |
| 534 statement.BindBlob(0, icon_data->front(), | |
| 535 static_cast<int>(icon_data->size())); | |
| 536 } else { | |
| 537 statement.BindNull(0); | |
| 538 } | |
| 539 statement.BindInt64(1, time.ToTimeT()); | |
| 540 statement.BindInt64(2, bitmap_id); | |
| 541 | |
| 511 return statement.Run(); | 542 return statement.Run(); |
| 512 } | 543 } |
| 513 | 544 |
| 545 bool ThumbnailDatabase::DeleteFaviconBitmap(FaviconBitmapID bitmap_id) { | |
| 546 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | |
| 547 "DELETE FROM favicon_bitmaps WHERE id=?")); | |
| 548 statement.BindInt64(0, bitmap_id); | |
| 549 return statement.Run(); | |
| 550 } | |
| 551 | |
| 514 bool ThumbnailDatabase::SetFaviconSizes(FaviconID icon_id, | 552 bool ThumbnailDatabase::SetFaviconSizes(FaviconID icon_id, |
| 515 const std::string& sizes) { | 553 const std::string& sizes) { |
| 516 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 554 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
| 517 "UPDATE favicons SET sizes=? WHERE id=?")); | 555 "UPDATE favicons SET sizes=? WHERE id=?")); |
| 518 statement.BindString(0, sizes); | 556 statement.BindString(0, sizes); |
| 519 statement.BindInt64(1, icon_id); | 557 statement.BindInt64(1, icon_id); |
| 520 | 558 |
| 521 return statement.Run(); | 559 return statement.Run(); |
| 522 } | 560 } |
| 523 | 561 |
| 524 bool ThumbnailDatabase::SetFaviconOutOfDate(FaviconID icon_id) { | 562 bool ThumbnailDatabase::SetFaviconOutOfDate(FaviconID icon_id) { |
| 525 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 563 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
| 526 "UPDATE favicon_bitmaps SET last_updated=? WHERE icon_id=?")); | 564 "UPDATE favicon_bitmaps SET last_updated=? WHERE icon_id=?")); |
| 527 statement.BindInt64(0, 0); | 565 statement.BindInt64(0, 0); |
| 528 statement.BindInt64(1, icon_id); | 566 statement.BindInt64(1, icon_id); |
| 529 | 567 |
| 530 return statement.Run(); | 568 return statement.Run(); |
| 531 } | 569 } |
| 532 | 570 |
| 533 FaviconID ThumbnailDatabase::GetFaviconIDForFaviconURL(const GURL& icon_url, | 571 FaviconID ThumbnailDatabase::GetFaviconIDForFaviconURL(const GURL& icon_url, |
| 534 int required_icon_type, | 572 int required_icon_type) { |
| 535 IconType* icon_type) { | |
| 536 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 573 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
| 537 "SELECT id, icon_type FROM favicons WHERE url=? AND (icon_type & ? > 0) " | 574 "SELECT id FROM favicons WHERE url=? AND (icon_type & ? > 0) " |
| 538 "ORDER BY icon_type DESC")); | 575 "ORDER BY icon_type DESC")); |
| 539 statement.BindString(0, URLDatabase::GURLToDatabaseURL(icon_url)); | 576 statement.BindString(0, URLDatabase::GURLToDatabaseURL(icon_url)); |
| 540 statement.BindInt(1, required_icon_type); | 577 statement.BindInt(1, required_icon_type); |
| 541 | 578 |
| 542 if (!statement.Step()) | 579 if (!statement.Step()) |
| 543 return 0; // not cached | 580 return 0; // not cached |
| 544 | |
| 545 if (icon_type) | |
| 546 *icon_type = static_cast<IconType>(statement.ColumnInt(1)); | |
| 547 return statement.ColumnInt64(0); | 581 return statement.ColumnInt64(0); |
| 548 } | 582 } |
| 549 | 583 |
| 550 bool ThumbnailDatabase::GetFavicon( | |
| 551 FaviconID icon_id, | |
| 552 base::Time* last_updated, | |
| 553 scoped_refptr<base::RefCountedMemory>* png_icon_data, | |
| 554 GURL* icon_url, | |
| 555 IconType* icon_type) { | |
| 556 DCHECK(icon_id); | |
| 557 | |
| 558 std::vector<FaviconBitmap> favicon_bitmaps; | |
| 559 if (!GetFaviconBitmaps(icon_id, &favicon_bitmaps)) | |
| 560 return false; | |
| 561 | |
| 562 if (favicon_bitmaps.empty()) | |
| 563 return false; | |
| 564 | |
| 565 if (last_updated) | |
| 566 *last_updated = favicon_bitmaps[0].last_updated; | |
| 567 | |
| 568 *png_icon_data = favicon_bitmaps[0].bitmap_data; | |
| 569 | |
| 570 return GetFaviconHeader(icon_id, icon_url, icon_type, NULL); | |
| 571 } | |
| 572 | |
| 573 bool ThumbnailDatabase::GetFaviconHeader( | 584 bool ThumbnailDatabase::GetFaviconHeader( |
| 574 FaviconID icon_id, | 585 FaviconID icon_id, |
| 575 GURL* icon_url, | 586 GURL* icon_url, |
| 576 IconType* icon_type, | 587 IconType* icon_type, |
| 577 std::string* sizes) { | 588 std::string* sizes) { |
| 578 DCHECK(icon_id); | 589 DCHECK(icon_id); |
| 579 | 590 |
| 580 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 591 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
| 581 "SELECT url, icon_type, sizes FROM favicons WHERE id=?")); | 592 "SELECT url, icon_type, sizes FROM favicons WHERE id=?")); |
| 582 statement.BindInt64(0, icon_id); | 593 statement.BindInt64(0, icon_id); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 630 statement.BindInt64(0, id); | 641 statement.BindInt64(0, id); |
| 631 if (!statement.Run()) | 642 if (!statement.Run()) |
| 632 return false; | 643 return false; |
| 633 | 644 |
| 634 statement.Assign(db_.GetCachedStatement(SQL_FROM_HERE, | 645 statement.Assign(db_.GetCachedStatement(SQL_FROM_HERE, |
| 635 "DELETE FROM favicon_bitmaps WHERE icon_id = ?")); | 646 "DELETE FROM favicon_bitmaps WHERE icon_id = ?")); |
| 636 statement.BindInt64(0, id); | 647 statement.BindInt64(0, id); |
| 637 return statement.Run(); | 648 return statement.Run(); |
| 638 } | 649 } |
| 639 | 650 |
| 640 bool ThumbnailDatabase::GetIconMappingForPageURL(const GURL& page_url, | 651 bool ThumbnailDatabase::GetIconMappingsForPageURL( |
| 641 IconType required_icon_type, | 652 const GURL& page_url, |
| 642 IconMapping* icon_mapping) { | 653 int required_icon_types, |
| 643 std::vector<IconMapping> icon_mappings; | 654 std::vector<IconMapping>* filtered_mapping_data) { |
| 644 if (!GetIconMappingsForPageURL(page_url, &icon_mappings)) | 655 std::vector<IconMapping> mapping_data; |
| 656 if (!GetIconMappingsForPageURL(page_url, &mapping_data)) | |
| 645 return false; | 657 return false; |
| 646 | 658 |
| 647 for (std::vector<IconMapping>::iterator m = icon_mappings.begin(); | 659 bool result = false; |
|
sky
2012/08/21 20:16:56
Same comment as in GetFaviconBitmapIDSizeListing:
| |
| 648 m != icon_mappings.end(); ++m) { | 660 for (std::vector<IconMapping>::iterator m = mapping_data.begin(); |
| 649 if (m->icon_type == required_icon_type) { | 661 m != mapping_data.end(); ++m) { |
| 650 if (icon_mapping != NULL) | 662 if (m->icon_type & required_icon_types) { |
| 651 *icon_mapping = *m; | 663 result = true; |
| 652 return true; | 664 if (filtered_mapping_data == NULL) |
| 665 return result; | |
| 666 filtered_mapping_data->push_back(*m); | |
| 653 } | 667 } |
| 654 } | 668 } |
| 655 | 669 return result; |
| 656 return false; | |
| 657 } | 670 } |
| 658 | 671 |
| 659 bool ThumbnailDatabase::GetIconMappingsForPageURL( | 672 bool ThumbnailDatabase::GetIconMappingsForPageURL( |
| 660 const GURL& page_url, | 673 const GURL& page_url, |
| 661 std::vector<IconMapping>* mapping_data) { | 674 std::vector<IconMapping>* mapping_data) { |
| 662 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 675 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
| 663 "SELECT icon_mapping.id, icon_mapping.icon_id, favicons.icon_type " | 676 "SELECT icon_mapping.id, icon_mapping.icon_id, favicons.icon_type, " |
| 677 "favicons.url " | |
| 664 "FROM icon_mapping " | 678 "FROM icon_mapping " |
| 665 "INNER JOIN favicons " | 679 "INNER JOIN favicons " |
| 666 "ON icon_mapping.icon_id = favicons.id " | 680 "ON icon_mapping.icon_id = favicons.id " |
| 667 "WHERE icon_mapping.page_url=? " | 681 "WHERE icon_mapping.page_url=? " |
| 668 "ORDER BY favicons.icon_type DESC")); | 682 "ORDER BY favicons.icon_type DESC")); |
| 669 statement.BindString(0, URLDatabase::GURLToDatabaseURL(page_url)); | 683 statement.BindString(0, URLDatabase::GURLToDatabaseURL(page_url)); |
| 670 | 684 |
| 671 bool result = false; | 685 bool result = false; |
| 672 while (statement.Step()) { | 686 while (statement.Step()) { |
| 673 result = true; | 687 result = true; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 697 } | 711 } |
| 698 | 712 |
| 699 bool ThumbnailDatabase::DeleteIconMappings(const GURL& page_url) { | 713 bool ThumbnailDatabase::DeleteIconMappings(const GURL& page_url) { |
| 700 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 714 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
| 701 "DELETE FROM icon_mapping WHERE page_url = ?")); | 715 "DELETE FROM icon_mapping WHERE page_url = ?")); |
| 702 statement.BindString(0, URLDatabase::GURLToDatabaseURL(page_url)); | 716 statement.BindString(0, URLDatabase::GURLToDatabaseURL(page_url)); |
| 703 | 717 |
| 704 return statement.Run(); | 718 return statement.Run(); |
| 705 } | 719 } |
| 706 | 720 |
| 721 bool ThumbnailDatabase::DeleteIconMapping(IconMappingID mapping_id) { | |
| 722 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | |
| 723 "DELETE FROM icon_mapping WHERE id=?")); | |
| 724 statement.BindInt64(0, mapping_id); | |
| 725 | |
| 726 return statement.Run(); | |
| 727 } | |
| 728 | |
| 707 bool ThumbnailDatabase::HasMappingFor(FaviconID id) { | 729 bool ThumbnailDatabase::HasMappingFor(FaviconID id) { |
| 708 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 730 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
| 709 "SELECT id FROM icon_mapping " | 731 "SELECT id FROM icon_mapping " |
| 710 "WHERE icon_id=?")); | 732 "WHERE icon_id=?")); |
| 711 statement.BindInt64(0, id); | 733 statement.BindInt64(0, id); |
| 712 | 734 |
| 713 return statement.Step(); | 735 return statement.Step(); |
| 714 } | 736 } |
| 715 | 737 |
| 716 bool ThumbnailDatabase::CloneIconMapping(const GURL& old_page_url, | 738 bool ThumbnailDatabase::CloneIconMappings(const GURL& old_page_url, |
| 717 const GURL& new_page_url) { | 739 const GURL& new_page_url) { |
| 718 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 740 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
| 719 "SELECT icon_id FROM icon_mapping " | 741 "SELECT icon_id FROM icon_mapping " |
| 720 "WHERE page_url=?")); | 742 "WHERE page_url=?")); |
| 721 if (!statement.is_valid()) | 743 if (!statement.is_valid()) |
| 722 return false; | 744 return false; |
| 723 | 745 |
| 724 // Do nothing if there are existing bindings | 746 // Do nothing if there are existing bindings |
| 725 statement.BindString(0, URLDatabase::GURLToDatabaseURL(new_page_url)); | 747 statement.BindString(0, URLDatabase::GURLToDatabaseURL(new_page_url)); |
| 726 if (statement.Step()) | 748 if (statement.Step()) |
| 727 return true; | 749 return true; |
| 728 | 750 |
| 729 statement.Assign(db_.GetCachedStatement(SQL_FROM_HERE, | 751 statement.Assign(db_.GetCachedStatement(SQL_FROM_HERE, |
| 730 "INSERT INTO icon_mapping (page_url, icon_id) " | 752 "INSERT INTO icon_mapping (page_url, icon_id) " |
| 731 "SELECT ?, icon_id FROM icon_mapping " | 753 "SELECT ?, icon_id FROM icon_mapping " |
| 732 "WHERE page_url = ?")); | 754 "WHERE page_url = ?")); |
| 733 | 755 |
| 734 statement.BindString(0, URLDatabase::GURLToDatabaseURL(new_page_url)); | 756 statement.BindString(0, URLDatabase::GURLToDatabaseURL(new_page_url)); |
| 735 statement.BindString(1, URLDatabase::GURLToDatabaseURL(old_page_url)); | 757 statement.BindString(1, URLDatabase::GURLToDatabaseURL(old_page_url)); |
| 736 return statement.Run(); | 758 return statement.Run(); |
| 737 } | 759 } |
| 738 | 760 |
| 739 bool ThumbnailDatabase::InitIconMappingEnumerator( | 761 bool ThumbnailDatabase::InitIconMappingEnumerator( |
| 740 IconType type, | 762 IconType type, |
| 741 IconMappingEnumerator* enumerator) { | 763 IconMappingEnumerator* enumerator) { |
| 742 DCHECK(!enumerator->statement_.is_valid()); | 764 DCHECK(!enumerator->statement_.is_valid()); |
| 743 enumerator->statement_.Assign(db_.GetCachedStatement( | 765 enumerator->statement_.Assign(db_.GetCachedStatement( |
| 744 SQL_FROM_HERE, | 766 SQL_FROM_HERE, |
| 745 "SELECT icon_mapping.id, icon_mapping.icon_id, favicons.icon_type, " | 767 "SELECT icon_mapping.id, icon_mapping.icon_id, favicons.icon_type, " |
| 746 "icon_mapping.page_url " | 768 "favicons.url, icon_mapping.page_url " |
| 747 "FROM icon_mapping JOIN favicons ON (" | 769 "FROM icon_mapping JOIN favicons ON (" |
| 748 "icon_mapping.icon_id = favicons.id) " | 770 "icon_mapping.icon_id = favicons.id) " |
| 749 "WHERE favicons.icon_type = ?")); | 771 "WHERE favicons.icon_type = ?")); |
| 750 enumerator->statement_.BindInt(0, type); | 772 enumerator->statement_.BindInt(0, type); |
| 751 return enumerator->statement_.is_valid(); | 773 return enumerator->statement_.is_valid(); |
| 752 } | 774 } |
| 753 | 775 |
| 754 bool ThumbnailDatabase::MigrateIconMappingData(URLDatabase* url_db) { | 776 bool ThumbnailDatabase::MigrateIconMappingData(URLDatabase* url_db) { |
| 755 URLDatabase::IconMappingEnumerator e; | 777 URLDatabase::IconMappingEnumerator e; |
| 756 if (!url_db->InitIconMappingEnumeratorForEverything(&e)) | 778 if (!url_db->InitIconMappingEnumeratorForEverything(&e)) |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1011 db_.Execute("ALTER TABLE temp_favicons RENAME TO favicons"); | 1033 db_.Execute("ALTER TABLE temp_favicons RENAME TO favicons"); |
| 1012 if (!success) | 1034 if (!success) |
| 1013 return false; | 1035 return false; |
| 1014 | 1036 |
| 1015 meta_table_.SetVersionNumber(6); | 1037 meta_table_.SetVersionNumber(6); |
| 1016 meta_table_.SetCompatibleVersionNumber(std::min(6, kCompatibleVersionNumber)); | 1038 meta_table_.SetCompatibleVersionNumber(std::min(6, kCompatibleVersionNumber)); |
| 1017 return true; | 1039 return true; |
| 1018 } | 1040 } |
| 1019 | 1041 |
| 1020 } // namespace history | 1042 } // namespace history |
| OLD | NEW |