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 15 matching lines...) Expand all Loading... |
26 #include "base/mac/mac_util.h" | 26 #include "base/mac/mac_util.h" |
27 #endif | 27 #endif |
28 | 28 |
29 static void FillIconMapping(const sql::Statement& statement, | 29 static void FillIconMapping(const sql::Statement& statement, |
30 const GURL& page_url, | 30 const GURL& page_url, |
31 history::IconMapping* icon_mapping) { | 31 history::IconMapping* icon_mapping) { |
32 icon_mapping->mapping_id = statement.ColumnInt64(0); | 32 icon_mapping->mapping_id = statement.ColumnInt64(0); |
33 icon_mapping->icon_id = statement.ColumnInt64(1); | 33 icon_mapping->icon_id = statement.ColumnInt64(1); |
34 icon_mapping->icon_type = | 34 icon_mapping->icon_type = |
35 static_cast<history::IconType>(statement.ColumnInt(2)); | 35 static_cast<history::IconType>(statement.ColumnInt(2)); |
| 36 icon_mapping->icon_url = GURL(statement.ColumnString(3)); |
36 icon_mapping->page_url = page_url; | 37 icon_mapping->page_url = page_url; |
37 } | 38 } |
38 | 39 |
39 namespace history { | 40 namespace history { |
40 | 41 |
41 // Version number of the database. | 42 // Version number of the database. |
42 static const int kCurrentVersionNumber = 6; | 43 static const int kCurrentVersionNumber = 6; |
43 static const int kCompatibleVersionNumber = 6; | 44 static const int kCompatibleVersionNumber = 6; |
44 | 45 |
45 // Use 90 quality (out of 100) which is pretty high, because we're very | 46 // Use 90 quality (out of 100) which is pretty high, because we're very |
46 // sensitive to artifacts for these small sized, highly detailed images. | 47 // sensitive to artifacts for these small sized, highly detailed images. |
47 static const int kImageQuality = 90; | 48 static const int kImageQuality = 90; |
48 | 49 |
49 ThumbnailDatabase::IconMappingEnumerator::IconMappingEnumerator() { | 50 ThumbnailDatabase::IconMappingEnumerator::IconMappingEnumerator() { |
50 } | 51 } |
51 | 52 |
52 ThumbnailDatabase::IconMappingEnumerator::~IconMappingEnumerator() { | 53 ThumbnailDatabase::IconMappingEnumerator::~IconMappingEnumerator() { |
53 } | 54 } |
54 | 55 |
55 bool ThumbnailDatabase::IconMappingEnumerator::GetNextIconMapping( | 56 bool ThumbnailDatabase::IconMappingEnumerator::GetNextIconMapping( |
56 IconMapping* icon_mapping) { | 57 IconMapping* icon_mapping) { |
57 if (!statement_.Step()) | 58 if (!statement_.Step()) |
58 return false; | 59 return false; |
59 FillIconMapping(statement_, GURL(statement_.ColumnString(3)), icon_mapping); | 60 FillIconMapping(statement_, GURL(statement_.ColumnString(4)), icon_mapping); |
60 return true; | 61 return true; |
61 } | 62 } |
62 | 63 |
63 ThumbnailDatabase::ThumbnailDatabase() | 64 ThumbnailDatabase::ThumbnailDatabase() |
64 : history_publisher_(NULL), | 65 : history_publisher_(NULL), |
65 use_top_sites_(false) { | 66 use_top_sites_(false) { |
66 } | 67 } |
67 | 68 |
68 sql::InitStatus ThumbnailDatabase::CantUpgradeToVersion(int cur_version) { | 69 sql::InitStatus ThumbnailDatabase::CantUpgradeToVersion(int cur_version) { |
69 LOG(WARNING) << "Unable to update to thumbnail database to version " << | 70 LOG(WARNING) << "Unable to update to thumbnail database to version " << |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 double current_boring_score = select_statement.ColumnDouble(0); | 394 double current_boring_score = select_statement.ColumnDouble(0); |
394 bool current_clipping = select_statement.ColumnBool(1); | 395 bool current_clipping = select_statement.ColumnBool(1); |
395 bool current_at_top = select_statement.ColumnBool(2); | 396 bool current_at_top = select_statement.ColumnBool(2); |
396 base::Time last_updated = | 397 base::Time last_updated = |
397 base::Time::FromTimeT(select_statement.ColumnInt64(3)); | 398 base::Time::FromTimeT(select_statement.ColumnInt64(3)); |
398 *score = ThumbnailScore(current_boring_score, current_clipping, | 399 *score = ThumbnailScore(current_boring_score, current_clipping, |
399 current_at_top, last_updated); | 400 current_at_top, last_updated); |
400 return true; | 401 return true; |
401 } | 402 } |
402 | 403 |
| 404 bool ThumbnailDatabase::GetFaviconBitmapIDSizeListing( |
| 405 FaviconID icon_id, |
| 406 std::vector<FaviconBitmapIDSize>* bitmap_id_size_listing) { |
| 407 DCHECK(icon_id); |
| 408 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
| 409 "SELECT id, width, height FROM favicon_bitmaps WHERE icon_id=?")); |
| 410 statement.BindInt64(0, icon_id); |
| 411 |
| 412 while (statement.Step()) { |
| 413 FaviconBitmapIDSize bitmap_id_size; |
| 414 bitmap_id_size.bitmap_id = statement.ColumnInt(0); |
| 415 bitmap_id_size.pixel_size = gfx::Size(statement.ColumnInt(1), |
| 416 statement.ColumnInt(2)); |
| 417 bitmap_id_size_listing->push_back(bitmap_id_size); |
| 418 } |
| 419 return !bitmap_id_size_listing->empty(); |
| 420 } |
| 421 |
403 bool ThumbnailDatabase::GetFaviconBitmaps( | 422 bool ThumbnailDatabase::GetFaviconBitmaps( |
404 FaviconID icon_id, | 423 FaviconID icon_id, |
405 std::vector<FaviconBitmap>* favicon_bitmaps) { | 424 std::vector<FaviconBitmap>* favicon_bitmaps) { |
406 DCHECK(icon_id); | 425 DCHECK(icon_id); |
407 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 426 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
408 "SELECT id, last_updated, image_data, width, height FROM favicon_bitmaps " | 427 "SELECT id, last_updated, image_data, width, height FROM favicon_bitmaps " |
409 "WHERE icon_id=?")); | 428 "WHERE icon_id=?")); |
410 statement.BindInt64(0, icon_id); | 429 statement.BindInt64(0, icon_id); |
411 | 430 |
412 bool result = false; | 431 bool result = false; |
(...skipping 12 matching lines...) Expand all Loading... |
425 statement.ColumnBlobAsVector(2, &data->data()); | 444 statement.ColumnBlobAsVector(2, &data->data()); |
426 favicon_bitmap.bitmap_data = data; | 445 favicon_bitmap.bitmap_data = data; |
427 } | 446 } |
428 favicon_bitmap.pixel_size = gfx::Size(statement.ColumnInt(3), | 447 favicon_bitmap.pixel_size = gfx::Size(statement.ColumnInt(3), |
429 statement.ColumnInt(4)); | 448 statement.ColumnInt(4)); |
430 favicon_bitmaps->push_back(favicon_bitmap); | 449 favicon_bitmaps->push_back(favicon_bitmap); |
431 } | 450 } |
432 return result; | 451 return result; |
433 } | 452 } |
434 | 453 |
| 454 bool ThumbnailDatabase::GetFaviconBitmap(FaviconBitmapID bitmap_id, |
| 455 FaviconBitmap* favicon_bitmap) { |
| 456 DCHECK(bitmap_id); |
| 457 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
| 458 "SELECT icon_id, last_updated, image_data, width, height " |
| 459 "FROM favicon_bitmaps WHERE id=?")); |
| 460 statement.BindInt64(0, bitmap_id); |
| 461 |
| 462 if (!statement.Step()) |
| 463 return false; // No entry for the id. |
| 464 |
| 465 if (favicon_bitmap) { |
| 466 favicon_bitmap->icon_id = statement.ColumnInt64(0); |
| 467 favicon_bitmap->last_updated = |
| 468 base::Time::FromTimeT(statement.ColumnInt64(1)); |
| 469 if (statement.ColumnByteLength(2) > 0) { |
| 470 scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes(); |
| 471 statement.ColumnBlobAsVector(2, &data->data()); |
| 472 favicon_bitmap->bitmap_data = data; |
| 473 } |
| 474 favicon_bitmap->pixel_size = gfx::Size(statement.ColumnInt(3), |
| 475 statement.ColumnInt(4)); |
| 476 } |
| 477 return true; |
| 478 } |
| 479 |
435 FaviconBitmapID ThumbnailDatabase::AddFaviconBitmap( | 480 FaviconBitmapID ThumbnailDatabase::AddFaviconBitmap( |
436 FaviconID icon_id, | 481 FaviconID icon_id, |
437 scoped_refptr<base::RefCountedMemory> icon_data, | 482 scoped_refptr<base::RefCountedMemory> icon_data, |
438 base::Time time, | 483 base::Time time, |
439 const gfx::Size& pixel_size) { | 484 const gfx::Size& pixel_size) { |
440 DCHECK(icon_id); | 485 DCHECK(icon_id); |
441 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 486 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
442 "INSERT INTO favicon_bitmaps (icon_id, image_data, last_updated, width, " | 487 "INSERT INTO favicon_bitmaps (icon_id, image_data, last_updated, width, " |
443 "height) VALUES (?, ?, ?, ?, ?)")); | 488 "height) VALUES (?, ?, ?, ?, ?)")); |
444 statement.BindInt64(0, icon_id); | 489 statement.BindInt64(0, icon_id); |
445 if (icon_data->size()) { | 490 if (icon_data->size()) { |
446 statement.BindBlob(1, icon_data->front(), | 491 statement.BindBlob(1, icon_data->front(), |
447 static_cast<int>(icon_data->size())); | 492 static_cast<int>(icon_data->size())); |
448 } else { | 493 } else { |
449 statement.BindNull(1); | 494 statement.BindNull(1); |
450 } | 495 } |
451 statement.BindInt64(2, time.ToTimeT()); | 496 statement.BindInt64(2, time.ToTimeT()); |
452 statement.BindInt(3, pixel_size.width()); | 497 statement.BindInt(3, pixel_size.width()); |
453 statement.BindInt(4, pixel_size.height()); | 498 statement.BindInt(4, pixel_size.height()); |
454 | 499 |
455 if (!statement.Run()) | 500 if (!statement.Run()) |
456 return 0; | 501 return 0; |
457 return db_.GetLastInsertRowId(); | 502 return db_.GetLastInsertRowId(); |
458 } | 503 } |
459 | 504 |
460 bool ThumbnailDatabase::SetFaviconBitmap( | 505 bool ThumbnailDatabase::SetFaviconBitmap( |
461 FaviconID icon_id, | 506 FaviconBitmapID bitmap_id, |
462 scoped_refptr<base::RefCountedMemory> icon_data, | 507 scoped_refptr<base::RefCountedMemory> icon_data, |
463 base::Time time) { | 508 base::Time time) { |
464 DCHECK(icon_id); | 509 DCHECK(bitmap_id); |
465 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 510 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
466 "UPDATE favicon_bitmaps SET image_data=?, last_updated=? " | 511 "UPDATE favicon_bitmaps SET image_data=?, last_updated=? WHERE id=?")); |
467 "WHERE icon_id=?")); | |
468 if (icon_data->size()) { | 512 if (icon_data->size()) { |
469 statement.BindBlob(0, icon_data->front(), | 513 statement.BindBlob(0, icon_data->front(), |
470 static_cast<int>(icon_data->size())); | 514 static_cast<int>(icon_data->size())); |
471 } else { | 515 } else { |
472 statement.BindNull(0); | 516 statement.BindNull(0); |
473 } | 517 } |
474 statement.BindInt64(1, time.ToTimeT()); | 518 statement.BindInt64(1, time.ToTimeT()); |
475 statement.BindInt64(2, icon_id); | 519 statement.BindInt64(2, bitmap_id); |
476 | 520 |
477 return statement.Run(); | 521 return statement.Run(); |
478 } | 522 } |
479 | 523 |
| 524 bool ThumbnailDatabase::DeleteFaviconBitmap(FaviconBitmapID bitmap_id) { |
| 525 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
| 526 "DELETE FROM favicon_bitmaps WHERE id=?")); |
| 527 statement.BindInt64(0, bitmap_id); |
| 528 return statement.Run(); |
| 529 } |
| 530 |
480 bool ThumbnailDatabase::SetFaviconSizes(FaviconID icon_id, | 531 bool ThumbnailDatabase::SetFaviconSizes(FaviconID icon_id, |
481 const std::string& sizes) { | 532 const std::string& sizes) { |
482 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 533 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
483 "UPDATE favicons SET sizes=? WHERE id=?")); | 534 "UPDATE favicons SET sizes=? WHERE id=?")); |
484 statement.BindString(0, sizes); | 535 statement.BindString(0, sizes); |
485 statement.BindInt64(1, icon_id); | 536 statement.BindInt64(1, icon_id); |
486 | 537 |
487 return statement.Run(); | 538 return statement.Run(); |
488 } | 539 } |
489 | 540 |
490 bool ThumbnailDatabase::SetFaviconOutOfDate(FaviconID icon_id) { | 541 bool ThumbnailDatabase::SetFaviconOutOfDate(FaviconID icon_id) { |
491 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 542 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
492 "UPDATE favicon_bitmaps SET last_updated=? WHERE icon_id=?")); | 543 "UPDATE favicon_bitmaps SET last_updated=? WHERE icon_id=?")); |
493 statement.BindInt64(0, 0); | 544 statement.BindInt64(0, 0); |
494 statement.BindInt64(1, icon_id); | 545 statement.BindInt64(1, icon_id); |
495 | 546 |
496 return statement.Run(); | 547 return statement.Run(); |
497 } | 548 } |
498 | 549 |
499 FaviconID ThumbnailDatabase::GetFaviconIDForFaviconURL(const GURL& icon_url, | 550 FaviconID ThumbnailDatabase::GetFaviconIDForFaviconURL(const GURL& icon_url, |
500 int required_icon_type, | 551 int required_icon_type) { |
501 IconType* icon_type) { | |
502 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 552 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
503 "SELECT id, icon_type FROM favicons WHERE url=? AND (icon_type & ? > 0) " | 553 "SELECT id FROM favicons WHERE url=? AND (icon_type & ? > 0) " |
504 "ORDER BY icon_type DESC")); | 554 "ORDER BY icon_type DESC")); |
505 statement.BindString(0, URLDatabase::GURLToDatabaseURL(icon_url)); | 555 statement.BindString(0, URLDatabase::GURLToDatabaseURL(icon_url)); |
506 statement.BindInt(1, required_icon_type); | 556 statement.BindInt(1, required_icon_type); |
507 | 557 |
508 if (!statement.Step()) | 558 if (!statement.Step()) |
509 return 0; // not cached | 559 return 0; // not cached |
510 | |
511 if (icon_type) | |
512 *icon_type = static_cast<IconType>(statement.ColumnInt(1)); | |
513 return statement.ColumnInt64(0); | 560 return statement.ColumnInt64(0); |
514 } | 561 } |
515 | 562 |
516 bool ThumbnailDatabase::GetFavicon( | |
517 FaviconID icon_id, | |
518 base::Time* last_updated, | |
519 scoped_refptr<base::RefCountedMemory>* png_icon_data, | |
520 GURL* icon_url, | |
521 IconType* icon_type) { | |
522 DCHECK(icon_id); | |
523 | |
524 std::vector<FaviconBitmap> favicon_bitmaps; | |
525 if (!GetFaviconBitmaps(icon_id, &favicon_bitmaps)) | |
526 return false; | |
527 | |
528 if (favicon_bitmaps.size() == 0) | |
529 return false; | |
530 | |
531 if (last_updated) | |
532 *last_updated = favicon_bitmaps[0].last_updated; | |
533 | |
534 *png_icon_data = favicon_bitmaps[0].bitmap_data; | |
535 | |
536 return GetFaviconHeader(icon_id, icon_url, icon_type, NULL); | |
537 } | |
538 | |
539 bool ThumbnailDatabase::GetFaviconHeader( | 563 bool ThumbnailDatabase::GetFaviconHeader( |
540 FaviconID icon_id, | 564 FaviconID icon_id, |
541 GURL* icon_url, | 565 GURL* icon_url, |
542 IconType* icon_type, | 566 IconType* icon_type, |
543 std::string* sizes) { | 567 std::string* sizes) { |
544 DCHECK(icon_id); | 568 DCHECK(icon_id); |
545 | 569 |
546 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 570 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
547 "SELECT url, icon_type, sizes FROM favicons WHERE id=?")); | 571 "SELECT url, icon_type, sizes FROM favicons WHERE id=?")); |
548 statement.BindInt64(0, icon_id); | 572 statement.BindInt64(0, icon_id); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 statement.BindInt64(0, id); | 620 statement.BindInt64(0, id); |
597 if (!statement.Run()) | 621 if (!statement.Run()) |
598 return false; | 622 return false; |
599 | 623 |
600 statement.Assign(db_.GetCachedStatement(SQL_FROM_HERE, | 624 statement.Assign(db_.GetCachedStatement(SQL_FROM_HERE, |
601 "DELETE FROM favicon_bitmaps WHERE icon_id = ?")); | 625 "DELETE FROM favicon_bitmaps WHERE icon_id = ?")); |
602 statement.BindInt64(0, id); | 626 statement.BindInt64(0, id); |
603 return statement.Run(); | 627 return statement.Run(); |
604 } | 628 } |
605 | 629 |
606 bool ThumbnailDatabase::GetIconMappingForPageURL(const GURL& page_url, | 630 bool ThumbnailDatabase::GetIconMappingsForPageURL( |
607 IconType required_icon_type, | 631 const GURL& page_url, |
608 IconMapping* icon_mapping) { | 632 int required_icon_types, |
609 std::vector<IconMapping> icon_mappings; | 633 std::vector<IconMapping>* filtered_mapping_data) { |
610 if (!GetIconMappingsForPageURL(page_url, &icon_mappings)) | 634 std::vector<IconMapping> mapping_data; |
| 635 if (!GetIconMappingsForPageURL(page_url, &mapping_data)) |
611 return false; | 636 return false; |
612 | 637 |
613 for (std::vector<IconMapping>::iterator m = icon_mappings.begin(); | 638 bool result = false; |
614 m != icon_mappings.end(); ++m) { | 639 for (std::vector<IconMapping>::iterator m = mapping_data.begin(); |
615 if (m->icon_type == required_icon_type) { | 640 m != mapping_data.end(); ++m) { |
616 if (icon_mapping != NULL) | 641 if (m->icon_type & required_icon_types) { |
617 *icon_mapping = *m; | 642 result = true; |
618 return true; | 643 if (filtered_mapping_data == NULL) |
| 644 return result; |
| 645 filtered_mapping_data->push_back(*m); |
619 } | 646 } |
620 } | 647 } |
621 | 648 return result; |
622 return false; | |
623 } | 649 } |
624 | 650 |
625 bool ThumbnailDatabase::GetIconMappingsForPageURL( | 651 bool ThumbnailDatabase::GetIconMappingsForPageURL( |
626 const GURL& page_url, | 652 const GURL& page_url, |
627 std::vector<IconMapping>* mapping_data) { | 653 std::vector<IconMapping>* mapping_data) { |
628 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 654 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
629 "SELECT icon_mapping.id, icon_mapping.icon_id, favicons.icon_type " | 655 "SELECT icon_mapping.id, icon_mapping.icon_id, favicons.icon_type, " |
| 656 "favicons.url " |
630 "FROM icon_mapping " | 657 "FROM icon_mapping " |
631 "INNER JOIN favicons " | 658 "INNER JOIN favicons " |
632 "ON icon_mapping.icon_id = favicons.id " | 659 "ON icon_mapping.icon_id = favicons.id " |
633 "WHERE icon_mapping.page_url=? " | 660 "WHERE icon_mapping.page_url=? " |
634 "ORDER BY favicons.icon_type DESC")); | 661 "ORDER BY favicons.icon_type DESC")); |
635 statement.BindString(0, URLDatabase::GURLToDatabaseURL(page_url)); | 662 statement.BindString(0, URLDatabase::GURLToDatabaseURL(page_url)); |
636 | 663 |
637 bool result = false; | 664 bool result = false; |
638 while (statement.Step()) { | 665 while (statement.Step()) { |
639 result = true; | 666 result = true; |
(...skipping 23 matching lines...) Expand all Loading... |
663 } | 690 } |
664 | 691 |
665 bool ThumbnailDatabase::DeleteIconMappings(const GURL& page_url) { | 692 bool ThumbnailDatabase::DeleteIconMappings(const GURL& page_url) { |
666 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 693 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
667 "DELETE FROM icon_mapping WHERE page_url = ?")); | 694 "DELETE FROM icon_mapping WHERE page_url = ?")); |
668 statement.BindString(0, URLDatabase::GURLToDatabaseURL(page_url)); | 695 statement.BindString(0, URLDatabase::GURLToDatabaseURL(page_url)); |
669 | 696 |
670 return statement.Run(); | 697 return statement.Run(); |
671 } | 698 } |
672 | 699 |
| 700 bool ThumbnailDatabase::DeleteIconMapping(IconMappingID mapping_id) { |
| 701 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
| 702 "DELETE FROM icon_mapping WHERE id=?")); |
| 703 statement.BindInt64(0, mapping_id); |
| 704 |
| 705 return statement.Run(); |
| 706 } |
| 707 |
673 bool ThumbnailDatabase::HasMappingFor(FaviconID id) { | 708 bool ThumbnailDatabase::HasMappingFor(FaviconID id) { |
674 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 709 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
675 "SELECT id FROM icon_mapping " | 710 "SELECT id FROM icon_mapping " |
676 "WHERE icon_id=?")); | 711 "WHERE icon_id=?")); |
677 statement.BindInt64(0, id); | 712 statement.BindInt64(0, id); |
678 | 713 |
679 return statement.Step(); | 714 return statement.Step(); |
680 } | 715 } |
681 | 716 |
682 bool ThumbnailDatabase::CloneIconMapping(const GURL& old_page_url, | 717 bool ThumbnailDatabase::CloneIconMapping(const GURL& old_page_url, |
(...skipping 19 matching lines...) Expand all Loading... |
702 return statement.Run(); | 737 return statement.Run(); |
703 } | 738 } |
704 | 739 |
705 bool ThumbnailDatabase::InitIconMappingEnumerator( | 740 bool ThumbnailDatabase::InitIconMappingEnumerator( |
706 IconType type, | 741 IconType type, |
707 IconMappingEnumerator* enumerator) { | 742 IconMappingEnumerator* enumerator) { |
708 DCHECK(!enumerator->statement_.is_valid()); | 743 DCHECK(!enumerator->statement_.is_valid()); |
709 enumerator->statement_.Assign(db_.GetCachedStatement( | 744 enumerator->statement_.Assign(db_.GetCachedStatement( |
710 SQL_FROM_HERE, | 745 SQL_FROM_HERE, |
711 "SELECT icon_mapping.id, icon_mapping.icon_id, favicons.icon_type, " | 746 "SELECT icon_mapping.id, icon_mapping.icon_id, favicons.icon_type, " |
712 "icon_mapping.page_url " | 747 "favicons.url, icon_mapping.page_url " |
713 "FROM icon_mapping JOIN favicons ON (" | 748 "FROM icon_mapping JOIN favicons ON (" |
714 "icon_mapping.icon_id = favicons.id) " | 749 "icon_mapping.icon_id = favicons.id) " |
715 "WHERE favicons.icon_type = ?")); | 750 "WHERE favicons.icon_type = ?")); |
716 enumerator->statement_.BindInt(0, type); | 751 enumerator->statement_.BindInt(0, type); |
717 return enumerator->statement_.is_valid(); | 752 return enumerator->statement_.is_valid(); |
718 } | 753 } |
719 | 754 |
720 bool ThumbnailDatabase::MigrateIconMappingData(URLDatabase* url_db) { | 755 bool ThumbnailDatabase::MigrateIconMappingData(URLDatabase* url_db) { |
721 URLDatabase::IconMappingEnumerator e; | 756 URLDatabase::IconMappingEnumerator e; |
722 if (!url_db->InitIconMappingEnumeratorForEverything(&e)) | 757 if (!url_db->InitIconMappingEnumeratorForEverything(&e)) |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 "SELECT id, url, icon_type FROM favicons") && | 1007 "SELECT id, url, icon_type FROM favicons") && |
973 db_.Execute("DROP TABLE favicons") && | 1008 db_.Execute("DROP TABLE favicons") && |
974 db_.Execute("ALTER TABLE temp_favicons RENAME TO favicons"); | 1009 db_.Execute("ALTER TABLE temp_favicons RENAME TO favicons"); |
975 | 1010 |
976 meta_table_.SetVersionNumber(6); | 1011 meta_table_.SetVersionNumber(6); |
977 meta_table_.SetCompatibleVersionNumber(std::min(6, kCompatibleVersionNumber)); | 1012 meta_table_.SetCompatibleVersionNumber(std::min(6, kCompatibleVersionNumber)); |
978 return success; | 1013 return success; |
979 } | 1014 } |
980 | 1015 |
981 } // namespace history | 1016 } // namespace history |
OLD | NEW |