| 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 "components/history/core/browser/history_backend.h" | 5 #include "components/history/core/browser/history_backend.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 #if defined(OS_IOS) | 273 #if defined(OS_IOS) |
| 274 void HistoryBackend::PersistState() { | 274 void HistoryBackend::PersistState() { |
| 275 Commit(); | 275 Commit(); |
| 276 } | 276 } |
| 277 #endif | 277 #endif |
| 278 | 278 |
| 279 void HistoryBackend::ClearCachedDataForContextID(ContextID context_id) { | 279 void HistoryBackend::ClearCachedDataForContextID(ContextID context_id) { |
| 280 tracker_.ClearCachedDataForContextID(context_id); | 280 tracker_.ClearCachedDataForContextID(context_id); |
| 281 } | 281 } |
| 282 | 282 |
| 283 base::FilePath HistoryBackend::GetThumbnailFileName() const { | |
| 284 return history_dir_.Append(kThumbnailsFilename); | |
| 285 } | |
| 286 | |
| 287 base::FilePath HistoryBackend::GetFaviconsFileName() const { | 283 base::FilePath HistoryBackend::GetFaviconsFileName() const { |
| 288 return history_dir_.Append(kFaviconsFilename); | 284 return history_dir_.Append(kFaviconsFilename); |
| 289 } | 285 } |
| 290 | 286 |
| 291 SegmentID HistoryBackend::GetLastSegmentID(VisitID from_visit) { | 287 SegmentID HistoryBackend::GetLastSegmentID(VisitID from_visit) { |
| 292 // Set is used to detect referrer loops. Should not happen, but can | 288 // Set is used to detect referrer loops. Should not happen, but can |
| 293 // if the database is corrupt. | 289 // if the database is corrupt. |
| 294 std::set<VisitID> visit_set; | 290 std::set<VisitID> visit_set; |
| 295 VisitID visit_id = from_visit; | 291 VisitID visit_id = from_visit; |
| 296 while (visit_id) { | 292 while (visit_id) { |
| (...skipping 2268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2565 } | 2561 } |
| 2566 | 2562 |
| 2567 bool HistoryBackend::ClearAllThumbnailHistory( | 2563 bool HistoryBackend::ClearAllThumbnailHistory( |
| 2568 const std::vector<GURL>& kept_urls) { | 2564 const std::vector<GURL>& kept_urls) { |
| 2569 if (!thumbnail_db_) { | 2565 if (!thumbnail_db_) { |
| 2570 // When we have no reference to the thumbnail database, maybe there was an | 2566 // When we have no reference to the thumbnail database, maybe there was an |
| 2571 // error opening it. In this case, we just try to blow it away to try to | 2567 // error opening it. In this case, we just try to blow it away to try to |
| 2572 // fix the error if it exists. This may fail, in which case either the | 2568 // fix the error if it exists. This may fail, in which case either the |
| 2573 // file doesn't exist or there's no more we can do. | 2569 // file doesn't exist or there's no more we can do. |
| 2574 sql::Connection::Delete(GetFaviconsFileName()); | 2570 sql::Connection::Delete(GetFaviconsFileName()); |
| 2575 | |
| 2576 // Older version of the database. | |
| 2577 sql::Connection::Delete(GetThumbnailFileName()); | |
| 2578 return true; | 2571 return true; |
| 2579 } | 2572 } |
| 2580 | 2573 |
| 2581 // Isolate from any long-running transaction. | 2574 // Isolate from any long-running transaction. |
| 2582 thumbnail_db_->CommitTransaction(); | 2575 thumbnail_db_->CommitTransaction(); |
| 2583 thumbnail_db_->BeginTransaction(); | 2576 thumbnail_db_->BeginTransaction(); |
| 2584 | 2577 |
| 2585 // TODO(shess): If this fails, perhaps the database should be razed | 2578 // TODO(shess): If this fails, perhaps the database should be razed |
| 2586 // or deleted. | 2579 // or deleted. |
| 2587 if (!thumbnail_db_->RetainDataForPageUrls(kept_urls)) { | 2580 if (!thumbnail_db_->RetainDataForPageUrls(kept_urls)) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2629 // transaction is currently open. | 2622 // transaction is currently open. |
| 2630 db_->CommitTransaction(); | 2623 db_->CommitTransaction(); |
| 2631 db_->Vacuum(); | 2624 db_->Vacuum(); |
| 2632 db_->BeginTransaction(); | 2625 db_->BeginTransaction(); |
| 2633 db_->GetStartDate(&first_recorded_time_); | 2626 db_->GetStartDate(&first_recorded_time_); |
| 2634 | 2627 |
| 2635 return true; | 2628 return true; |
| 2636 } | 2629 } |
| 2637 | 2630 |
| 2638 } // namespace history | 2631 } // namespace history |
| OLD | NEW |