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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 // the data is complete. | 181 // the data is complete. |
182 recent_changes_.Put(url, PageInfo(url_id, visit_id, time)); | 182 recent_changes_.Put(url, PageInfo(url_id, visit_id, time)); |
183 } | 183 } |
184 | 184 |
185 void TextDatabaseManager::AddPageTitle(const GURL& url, | 185 void TextDatabaseManager::AddPageTitle(const GURL& url, |
186 const string16& title) { | 186 const string16& title) { |
187 RecentChangeList::iterator found = recent_changes_.Peek(url); | 187 RecentChangeList::iterator found = recent_changes_.Peek(url); |
188 if (found == recent_changes_.end()) { | 188 if (found == recent_changes_.end()) { |
189 // This page is not in our cache of recent pages. This is very much an edge | 189 // This page is not in our cache of recent pages. This is very much an edge |
190 // case as normally a title will come in <20 seconds after the page commits, | 190 // case as normally a title will come in <20 seconds after the page commits, |
191 // and TabContents will avoid spamming us with >1 title per page. However, | 191 // and WebContents will avoid spamming us with >1 title per page. However, |
192 // it could come up if your connection is unhappy, and we don't want to | 192 // it could come up if your connection is unhappy, and we don't want to |
193 // miss anything. | 193 // miss anything. |
194 // | 194 // |
195 // To solve this problem, we'll just associate the most recent visit with | 195 // To solve this problem, we'll just associate the most recent visit with |
196 // the new title and index that using the regular code path. | 196 // the new title and index that using the regular code path. |
197 URLRow url_row; | 197 URLRow url_row; |
198 if (!url_database_->GetRowForURL(url, &url_row)) | 198 if (!url_database_->GetRowForURL(url, &url_row)) |
199 return; // URL is unknown, give up. | 199 return; // URL is unknown, give up. |
200 VisitRow visit; | 200 VisitRow visit; |
201 if (!visit_database_->GetMostRecentVisitForURL(url_row.id(), &visit)) | 201 if (!visit_database_->GetMostRecentVisitForURL(url_row.id(), &visit)) |
(...skipping 350 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 |