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 "chrome/browser/history/text_database_manager.h" | 5 #include "chrome/browser/history/text_database_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 info.set_title(title); | 230 info.set_title(title); |
231 } | 231 } |
232 | 232 |
233 void TextDatabaseManager::AddPageContents(const GURL& url, | 233 void TextDatabaseManager::AddPageContents(const GURL& url, |
234 const string16& body) { | 234 const string16& body) { |
235 RecentChangeList::iterator found = recent_changes_.Peek(url); | 235 RecentChangeList::iterator found = recent_changes_.Peek(url); |
236 if (found == recent_changes_.end()) { | 236 if (found == recent_changes_.end()) { |
237 // This page is not in our cache of recent pages. This means that the page | 237 // This page is not in our cache of recent pages. This means that the page |
238 // took more than kExpirationSeconds to load. Often, this will be the result | 238 // took more than kExpirationSeconds to load. Often, this will be the result |
239 // of a very slow iframe or other resource on the page that makes us think | 239 // of a very slow iframe or other resource on the page that makes us think |
240 // its still loading. | 240 // it's still loading. |
241 // | 241 // |
242 // As a fallback, set the most recent visit's contents using the input, and | 242 // As a fallback, set the most recent visit's contents using the input, and |
243 // use the last set title in the URL table as the title to index. | 243 // use the last set title in the URL table as the title to index. |
244 URLRow url_row; | 244 URLRow url_row; |
245 if (!url_database_->GetRowForURL(url, &url_row)) | 245 if (!url_database_->GetRowForURL(url, &url_row)) |
246 return; // URL is unknown, give up. | 246 return; // URL is unknown, give up. |
247 VisitRow visit; | 247 VisitRow visit; |
248 if (!visit_database_->GetMostRecentVisitForURL(url_row.id(), &visit)) | 248 if (!visit_database_->GetMostRecentVisitForURL(url_row.id(), &visit)) |
249 return; // No recent visit, give up. | 249 return; // No recent visit, give up. |
250 | 250 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 while (i != recent_changes_.rend() && i->second.Expired(now)) { | 552 while (i != recent_changes_.rend() && i->second.Expired(now)) { |
553 AddPageData(i->first, i->second.url_id(), i->second.visit_id(), | 553 AddPageData(i->first, i->second.url_id(), i->second.visit_id(), |
554 i->second.visit_time(), i->second.title(), i->second.body()); | 554 i->second.visit_time(), i->second.title(), i->second.body()); |
555 i = recent_changes_.Erase(i); | 555 i = recent_changes_.Erase(i); |
556 } | 556 } |
557 | 557 |
558 ScheduleFlushOldChanges(); | 558 ScheduleFlushOldChanges(); |
559 } | 559 } |
560 | 560 |
561 } // namespace history | 561 } // namespace history |
OLD | NEW |