OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/history_backend.h" | 5 #include "chrome/browser/history/history_backend.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 } | 522 } |
523 | 523 |
524 // Full-text database. This has to be first so we can pass it to the | 524 // Full-text database. This has to be first so we can pass it to the |
525 // HistoryDatabase for migration. | 525 // HistoryDatabase for migration. |
526 text_database_.reset(new TextDatabaseManager(history_dir_, | 526 text_database_.reset(new TextDatabaseManager(history_dir_, |
527 db_.get(), db_.get())); | 527 db_.get(), db_.get())); |
528 if (!text_database_->Init(history_publisher_.get())) { | 528 if (!text_database_->Init(history_publisher_.get())) { |
529 LOG(WARNING) << "Text database initialization failed, running without it."; | 529 LOG(WARNING) << "Text database initialization failed, running without it."; |
530 text_database_.reset(); | 530 text_database_.reset(); |
531 } | 531 } |
| 532 if (db_->needs_version_17_migration()) { |
| 533 // See needs_version_17_migration() decl for more. In this case, we want |
| 534 // to erase all the text database files. This must be done after the text |
| 535 // database manager has been initialized, since it knows about all the |
| 536 // files it manages. |
| 537 text_database_->DeleteAll(); |
| 538 } |
532 | 539 |
533 // Thumbnail database. | 540 // Thumbnail database. |
534 thumbnail_db_.reset(new ThumbnailDatabase()); | 541 thumbnail_db_.reset(new ThumbnailDatabase()); |
535 if (thumbnail_db_->Init(thumbnail_name, | 542 if (thumbnail_db_->Init(thumbnail_name, |
536 history_publisher_.get()) != INIT_OK) { | 543 history_publisher_.get()) != INIT_OK) { |
537 // Unlike the main database, we don't error out when the database is too | 544 // Unlike the main database, we don't error out when the database is too |
538 // new because this error is much less severe. Generally, this shouldn't | 545 // new because this error is much less severe. Generally, this shouldn't |
539 // happen since the thumbnail and main datbase versions should be in sync. | 546 // happen since the thumbnail and main datbase versions should be in sync. |
540 // We'll just continue without thumbnails & favicons in this case or any | 547 // We'll just continue without thumbnails & favicons in this case or any |
541 // other error. | 548 // other error. |
542 LOG(WARNING) << "Could not initialize the thumbnail database."; | 549 LOG(WARNING) << "Could not initialize the thumbnail database."; |
543 thumbnail_db_.reset(); | 550 thumbnail_db_.reset(); |
544 } | 551 } |
545 | 552 |
546 // Archived database. | 553 // Archived database. |
| 554 if (db_->needs_version_17_migration()) { |
| 555 // See needs_version_17_migration() decl for more. In this case, we want |
| 556 // to delete the archived database and need to do so before we try to |
| 557 // open the file. We can ignore any error (maybe the file doesn't exist). |
| 558 file_util::Delete(archived_name, false); |
| 559 } |
547 archived_db_.reset(new ArchivedDatabase()); | 560 archived_db_.reset(new ArchivedDatabase()); |
548 if (!archived_db_->Init(archived_name)) { | 561 if (!archived_db_->Init(archived_name)) { |
549 LOG(WARNING) << "Could not initialize the archived database."; | 562 LOG(WARNING) << "Could not initialize the archived database."; |
550 archived_db_.reset(); | 563 archived_db_.reset(); |
551 } | 564 } |
552 | 565 |
553 // Tell the expiration module about all the nice databases we made. This must | 566 // Tell the expiration module about all the nice databases we made. This must |
554 // happen before db_->Init() is called since the callback ForceArchiveHistory | 567 // happen before db_->Init() is called since the callback ForceArchiveHistory |
555 // may need to expire stuff. | 568 // may need to expire stuff. |
556 // | 569 // |
(...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1938 return true; | 1951 return true; |
1939 } | 1952 } |
1940 | 1953 |
1941 BookmarkService* HistoryBackend::GetBookmarkService() { | 1954 BookmarkService* HistoryBackend::GetBookmarkService() { |
1942 if (bookmark_service_) | 1955 if (bookmark_service_) |
1943 bookmark_service_->BlockTillLoaded(); | 1956 bookmark_service_->BlockTillLoaded(); |
1944 return bookmark_service_; | 1957 return bookmark_service_; |
1945 } | 1958 } |
1946 | 1959 |
1947 } // namespace history | 1960 } // namespace history |
OLD | NEW |