| 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 241 |
| 242 FilePath HistoryBackend::GetThumbnailFileName() const { | 242 FilePath HistoryBackend::GetThumbnailFileName() const { |
| 243 return history_dir_.Append(chrome::kThumbnailsFilename); | 243 return history_dir_.Append(chrome::kThumbnailsFilename); |
| 244 } | 244 } |
| 245 | 245 |
| 246 FilePath HistoryBackend::GetArchivedFileName() const { | 246 FilePath HistoryBackend::GetArchivedFileName() const { |
| 247 return history_dir_.Append(chrome::kArchivedHistoryFilename); | 247 return history_dir_.Append(chrome::kArchivedHistoryFilename); |
| 248 } | 248 } |
| 249 | 249 |
| 250 SegmentID HistoryBackend::GetLastSegmentID(VisitID from_visit) { | 250 SegmentID HistoryBackend::GetLastSegmentID(VisitID from_visit) { |
| 251 // Set is used to detect referrer loops. Should not happen, but can |
| 252 // if the database is corrupt. |
| 253 std::set<VisitID> visit_set; |
| 251 VisitID visit_id = from_visit; | 254 VisitID visit_id = from_visit; |
| 252 while (visit_id) { | 255 while (visit_id) { |
| 253 VisitRow row; | 256 VisitRow row; |
| 254 if (!db_->GetRowForVisit(visit_id, &row)) | 257 if (!db_->GetRowForVisit(visit_id, &row)) |
| 255 return 0; | 258 return 0; |
| 256 if (row.segment_id) | 259 if (row.segment_id) |
| 257 return row.segment_id; // Found a visit in this change with a segment. | 260 return row.segment_id; // Found a visit in this change with a segment. |
| 258 | 261 |
| 259 // Check the referrer of this visit, if any. | 262 // Check the referrer of this visit, if any. |
| 260 visit_id = row.referring_visit; | 263 visit_id = row.referring_visit; |
| 264 |
| 265 if (visit_set.find(visit_id) != visit_set.end()) { |
| 266 NOTREACHED() << "Loop in referer chain, giving up"; |
| 267 break; |
| 268 } |
| 269 visit_set.insert(visit_id); |
| 261 } | 270 } |
| 262 return 0; | 271 return 0; |
| 263 } | 272 } |
| 264 | 273 |
| 265 SegmentID HistoryBackend::UpdateSegments(const GURL& url, | 274 SegmentID HistoryBackend::UpdateSegments(const GURL& url, |
| 266 VisitID from_visit, | 275 VisitID from_visit, |
| 267 VisitID visit_id, | 276 VisitID visit_id, |
| 268 PageTransition::Type transition_type, | 277 PageTransition::Type transition_type, |
| 269 const Time ts) { | 278 const Time ts) { |
| 270 if (!db_.get()) | 279 if (!db_.get()) |
| (...skipping 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1968 return true; | 1977 return true; |
| 1969 } | 1978 } |
| 1970 | 1979 |
| 1971 BookmarkService* HistoryBackend::GetBookmarkService() { | 1980 BookmarkService* HistoryBackend::GetBookmarkService() { |
| 1972 if (bookmark_service_) | 1981 if (bookmark_service_) |
| 1973 bookmark_service_->BlockTillLoaded(); | 1982 bookmark_service_->BlockTillLoaded(); |
| 1974 return bookmark_service_; | 1983 return bookmark_service_; |
| 1975 } | 1984 } |
| 1976 | 1985 |
| 1977 } // namespace history | 1986 } // namespace history |
| OLD | NEW |