Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(602)

Side by Side Diff: chrome/browser/history/thumbnail_database.cc

Issue 57463009: [sql] Track data recovered in Favicons recovery. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bind.h" 10 #include "base/bind.h"
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 "INSERT OR REPLACE INTO main.favicons " 524 "INSERT OR REPLACE INTO main.favicons "
525 "SELECT id, url, COALESCE(icon_type, 1) FROM recover_favicons"; 525 "SELECT id, url, COALESCE(icon_type, 1) FROM recover_favicons";
526 if (!recovery->db()->Execute(kCopySql)) { 526 if (!recovery->db()->Execute(kCopySql)) {
527 // TODO(shess): The recover_favicons table should mask problems 527 // TODO(shess): The recover_favicons table should mask problems
528 // with the source file, so this implies failure to write to the 528 // with the source file, so this implies failure to write to the
529 // recovery database. 529 // recovery database.
530 sql::Recovery::Rollback(recovery.Pass()); 530 sql::Recovery::Rollback(recovery.Pass());
531 RecordRecoveryEvent(RECOVERY_EVENT_FAILED_FAVICONS_INSERT); 531 RecordRecoveryEvent(RECOVERY_EVENT_FAILED_FAVICONS_INSERT);
532 return; 532 return;
533 } 533 }
534 favicons_rows_recovered = recovery->db()->GetLastChangeCount();
534 } 535 }
535 536
536 // Setup favicons_bitmaps table. 537 // Setup favicons_bitmaps table.
537 { 538 {
538 const char kRecoverySql[] = 539 const char kRecoverySql[] =
539 "CREATE VIRTUAL TABLE temp.recover_favicons_bitmaps USING recover" 540 "CREATE VIRTUAL TABLE temp.recover_favicons_bitmaps USING recover"
540 "(" 541 "("
541 "corrupt.favicon_bitmaps," 542 "corrupt.favicon_bitmaps,"
542 "id ROWID," 543 "id ROWID,"
543 "icon_id INTEGER STRICT NOT NULL," 544 "icon_id INTEGER STRICT NOT NULL,"
(...skipping 16 matching lines...) Expand all
560 " COALESCE(width, 0), COALESCE(height, 0) " 561 " COALESCE(width, 0), COALESCE(height, 0) "
561 "FROM recover_favicons_bitmaps"; 562 "FROM recover_favicons_bitmaps";
562 if (!recovery->db()->Execute(kCopySql)) { 563 if (!recovery->db()->Execute(kCopySql)) {
563 // TODO(shess): The recover_faviconbitmaps table should mask 564 // TODO(shess): The recover_faviconbitmaps table should mask
564 // problems with the source file, so this implies failure to 565 // problems with the source file, so this implies failure to
565 // write to the recovery database. 566 // write to the recovery database.
566 sql::Recovery::Rollback(recovery.Pass()); 567 sql::Recovery::Rollback(recovery.Pass());
567 RecordRecoveryEvent(RECOVERY_EVENT_FAILED_FAVICON_BITMAPS_INSERT); 568 RecordRecoveryEvent(RECOVERY_EVENT_FAILED_FAVICON_BITMAPS_INSERT);
568 return; 569 return;
569 } 570 }
571 favicon_bitmaps_rows_recovered = recovery->db()->GetLastChangeCount();
570 } 572 }
571 573
572 // Setup icon_mapping table. 574 // Setup icon_mapping table.
573 { 575 {
574 const char kRecoverySql[] = 576 const char kRecoverySql[] =
575 "CREATE VIRTUAL TABLE temp.recover_icon_mapping USING recover" 577 "CREATE VIRTUAL TABLE temp.recover_icon_mapping USING recover"
576 "(" 578 "("
577 "corrupt.icon_mapping," 579 "corrupt.icon_mapping,"
578 "id ROWID," 580 "id ROWID,"
579 "page_url TEXT STRICT NOT NULL," 581 "page_url TEXT STRICT NOT NULL,"
(...skipping 11 matching lines...) Expand all
591 "INSERT OR REPLACE INTO main.icon_mapping " 593 "INSERT OR REPLACE INTO main.icon_mapping "
592 "SELECT id, page_url, icon_id FROM recover_icon_mapping"; 594 "SELECT id, page_url, icon_id FROM recover_icon_mapping";
593 if (!recovery->db()->Execute(kCopySql)) { 595 if (!recovery->db()->Execute(kCopySql)) {
594 // TODO(shess): The recover_icon_mapping table should mask 596 // TODO(shess): The recover_icon_mapping table should mask
595 // problems with the source file, so this implies failure to 597 // problems with the source file, so this implies failure to
596 // write to the recovery database. 598 // write to the recovery database.
597 sql::Recovery::Rollback(recovery.Pass()); 599 sql::Recovery::Rollback(recovery.Pass());
598 RecordRecoveryEvent(RECOVERY_EVENT_FAILED_ICON_MAPPING_INSERT); 600 RecordRecoveryEvent(RECOVERY_EVENT_FAILED_ICON_MAPPING_INSERT);
599 return; 601 return;
600 } 602 }
603 icon_mapping_rows_recovered = recovery->db()->GetLastChangeCount();
601 } 604 }
602 605
603 // TODO(shess): Is it possible/likely to have broken foreign-key 606 // TODO(shess): Is it possible/likely to have broken foreign-key
604 // issues with the tables? 607 // issues with the tables?
605 // - icon_mapping.icon_id maps to no favicons.id 608 // - icon_mapping.icon_id maps to no favicons.id
606 // - favicon_bitmaps.icon_id maps to no favicons.id 609 // - favicon_bitmaps.icon_id maps to no favicons.id
607 // - favicons.id is referenced by no icon_mapping.icon_id 610 // - favicons.id is referenced by no icon_mapping.icon_id
608 // - favicons.id is referenced by no favicon_bitmaps.icon_id 611 // - favicons.id is referenced by no favicon_bitmaps.icon_id
609 // This step is possibly not worth the effort necessary to develop 612 // This step is possibly not worth the effort necessary to develop
610 // and sequence the statements, as it is basically a form of garbage 613 // and sequence the statements, as it is basically a form of garbage
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 meta_table_.SetVersionNumber(7); 1421 meta_table_.SetVersionNumber(7);
1419 meta_table_.SetCompatibleVersionNumber(std::min(7, kCompatibleVersionNumber)); 1422 meta_table_.SetCompatibleVersionNumber(std::min(7, kCompatibleVersionNumber));
1420 return true; 1423 return true;
1421 } 1424 }
1422 1425
1423 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { 1426 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() {
1424 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); 1427 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons");
1425 } 1428 }
1426 1429
1427 } // namespace history 1430 } // namespace history
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698