| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 538 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
| 539 "SELECT id FROM icon_mapping " | 539 "SELECT id FROM icon_mapping " |
| 540 "WHERE icon_id=?")); | 540 "WHERE icon_id=?")); |
| 541 if (!statement) | 541 if (!statement) |
| 542 return false; | 542 return false; |
| 543 | 543 |
| 544 statement.BindInt64(0, id); | 544 statement.BindInt64(0, id); |
| 545 return statement.Step(); | 545 return statement.Step(); |
| 546 } | 546 } |
| 547 | 547 |
| 548 bool ThumbnailDatabase::CloneIconMapping(const GURL& old_page_url, |
| 549 const GURL& new_page_url) { |
| 550 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
| 551 "SELECT icon_id FROM icon_mapping " |
| 552 "WHERE page_url=?")); |
| 553 if (!statement) |
| 554 return false; |
| 555 |
| 556 // Do nothing if there are existing bindings |
| 557 statement.BindString(0, URLDatabase::GURLToDatabaseURL(new_page_url)); |
| 558 if (statement.Step()) |
| 559 return true; |
| 560 |
| 561 statement.Assign(db_.GetCachedStatement(SQL_FROM_HERE, |
| 562 "INSERT INTO icon_mapping (page_url, icon_id) " |
| 563 "SELECT ?, icon_id FROM icon_mapping " |
| 564 "WHERE page_url = ?")); |
| 565 if (!statement) |
| 566 return false; |
| 567 |
| 568 statement.BindString(0, URLDatabase::GURLToDatabaseURL(new_page_url)); |
| 569 statement.BindString(1, URLDatabase::GURLToDatabaseURL(old_page_url)); |
| 570 return statement.Run(); |
| 571 } |
| 572 |
| 573 |
| 548 bool ThumbnailDatabase::MigrateIconMappingData(URLDatabase* url_db) { | 574 bool ThumbnailDatabase::MigrateIconMappingData(URLDatabase* url_db) { |
| 549 URLDatabase::IconMappingEnumerator e; | 575 URLDatabase::IconMappingEnumerator e; |
| 550 if (!url_db->InitIconMappingEnumeratorForEverything(&e)) | 576 if (!url_db->InitIconMappingEnumeratorForEverything(&e)) |
| 551 return false; | 577 return false; |
| 552 | 578 |
| 553 IconMapping info; | 579 IconMapping info; |
| 554 while (e.GetNextIconMapping(&info)) { | 580 while (e.GetNextIconMapping(&info)) { |
| 555 // TODO: Using bulk insert to improve the performance. | 581 // TODO: Using bulk insert to improve the performance. |
| 556 if (!AddIconMapping(info.page_url, info.icon_id)) | 582 if (!AddIconMapping(info.page_url, info.icon_id)) |
| 557 return false; | 583 return false; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 if (!db_.Execute("ALTER TABLE favicons ADD sizes LONGVARCHAR")) { | 779 if (!db_.Execute("ALTER TABLE favicons ADD sizes LONGVARCHAR")) { |
| 754 NOTREACHED(); | 780 NOTREACHED(); |
| 755 return false; | 781 return false; |
| 756 } | 782 } |
| 757 meta_table_.SetVersionNumber(5); | 783 meta_table_.SetVersionNumber(5); |
| 758 meta_table_.SetCompatibleVersionNumber(std::min(5, kCompatibleVersionNumber)); | 784 meta_table_.SetCompatibleVersionNumber(std::min(5, kCompatibleVersionNumber)); |
| 759 return true; | 785 return true; |
| 760 } | 786 } |
| 761 | 787 |
| 762 } // namespace history | 788 } // namespace history |
| OLD | NEW |