OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 if (thumbnail_db_.get()) | 560 if (thumbnail_db_.get()) |
561 thumbnail_db_->BeginTransaction(); | 561 thumbnail_db_->BeginTransaction(); |
562 if (archived_db_.get()) | 562 if (archived_db_.get()) |
563 archived_db_->BeginTransaction(); | 563 archived_db_->BeginTransaction(); |
564 if (text_database_.get()) | 564 if (text_database_.get()) |
565 text_database_->BeginTransaction(); | 565 text_database_->BeginTransaction(); |
566 | 566 |
567 // Start expiring old stuff. | 567 // Start expiring old stuff. |
568 expirer_.StartArchivingOldStuff(TimeDelta::FromDays(kArchiveDaysThreshold)); | 568 expirer_.StartArchivingOldStuff(TimeDelta::FromDays(kArchiveDaysThreshold)); |
569 | 569 |
570 HISTOGRAM_TIMES(L"History.InitTime", | 570 HISTOGRAM_TIMES("History.InitTime", |
571 TimeTicks::Now() - beginning_time); | 571 TimeTicks::Now() - beginning_time); |
572 } | 572 } |
573 | 573 |
574 std::pair<URLID, VisitID> HistoryBackend::AddPageVisit( | 574 std::pair<URLID, VisitID> HistoryBackend::AddPageVisit( |
575 const GURL& url, | 575 const GURL& url, |
576 Time time, | 576 Time time, |
577 VisitID referring_visit, | 577 VisitID referring_visit, |
578 PageTransition::Type transition) { | 578 PageTransition::Type transition) { |
579 // Top-level frame navigations are visible, everything else is hidden | 579 // Top-level frame navigations are visible, everything else is hidden |
580 bool new_hidden = !PageTransition::IsMainFrame(transition); | 580 bool new_hidden = !PageTransition::IsMainFrame(transition); |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 // expirer_.GetCurrentArchiveTime() - TimeDelta::FromDays(7)) { | 990 // expirer_.GetCurrentArchiveTime() - TimeDelta::FromDays(7)) { |
991 } else { | 991 } else { |
992 // Full text history query. | 992 // Full text history query. |
993 QueryHistoryFTS(text_query, options, &request->value); | 993 QueryHistoryFTS(text_query, options, &request->value); |
994 } | 994 } |
995 } | 995 } |
996 | 996 |
997 request->ForwardResult(QueryHistoryRequest::TupleType(request->handle(), | 997 request->ForwardResult(QueryHistoryRequest::TupleType(request->handle(), |
998 &request->value)); | 998 &request->value)); |
999 | 999 |
1000 HISTOGRAM_TIMES(L"History.QueryHistory", | 1000 HISTOGRAM_TIMES("History.QueryHistory", |
1001 TimeTicks::Now() - beginning_time); | 1001 TimeTicks::Now() - beginning_time); |
1002 } | 1002 } |
1003 | 1003 |
1004 // Basic time-based querying of history. | 1004 // Basic time-based querying of history. |
1005 void HistoryBackend::QueryHistoryBasic(URLDatabase* url_db, | 1005 void HistoryBackend::QueryHistoryBasic(URLDatabase* url_db, |
1006 VisitDatabase* visit_db, | 1006 VisitDatabase* visit_db, |
1007 const QueryOptions& options, | 1007 const QueryOptions& options, |
1008 QueryResults* result) { | 1008 QueryResults* result) { |
1009 // First get all visits. | 1009 // First get all visits. |
1010 VisitVector visits; | 1010 VisitVector visits; |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1224 | 1224 |
1225 // In this rare case, we start to mine the older redirect sessions | 1225 // In this rare case, we start to mine the older redirect sessions |
1226 // from the visit table to try to find a thumbnail. | 1226 // from the visit table to try to find a thumbnail. |
1227 if (!success) { | 1227 if (!success) { |
1228 success = GetThumbnailFromOlderRedirect(page_url, &(*data)->data); | 1228 success = GetThumbnailFromOlderRedirect(page_url, &(*data)->data); |
1229 } | 1229 } |
1230 | 1230 |
1231 if (!success) | 1231 if (!success) |
1232 *data = NULL; // This will tell the callback there was an error. | 1232 *data = NULL; // This will tell the callback there was an error. |
1233 | 1233 |
1234 HISTOGRAM_TIMES(L"History.GetPageThumbnail", | 1234 HISTOGRAM_TIMES("History.GetPageThumbnail", |
1235 TimeTicks::Now() - beginning_time); | 1235 TimeTicks::Now() - beginning_time); |
1236 } | 1236 } |
1237 } | 1237 } |
1238 | 1238 |
1239 bool HistoryBackend::GetThumbnailFromOlderRedirect( | 1239 bool HistoryBackend::GetThumbnailFromOlderRedirect( |
1240 const GURL& page_url, | 1240 const GURL& page_url, |
1241 std::vector<unsigned char>* data) { | 1241 std::vector<unsigned char>* data) { |
1242 // Look at a few previous visit sessions. | 1242 // Look at a few previous visit sessions. |
1243 VisitVector older_sessions; | 1243 VisitVector older_sessions; |
1244 URLID page_url_id = db_->GetRowForURL(page_url, NULL); | 1244 URLID page_url_id = db_->GetRowForURL(page_url, NULL); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1390 data = new RefCountedBytes; | 1390 data = new RefCountedBytes; |
1391 Time last_updated; | 1391 Time last_updated; |
1392 if (db_->GetRowForURL(page_url, &url_info) && url_info.favicon_id() && | 1392 if (db_->GetRowForURL(page_url, &url_info) && url_info.favicon_id() && |
1393 thumbnail_db_->GetFavIcon(url_info.favicon_id(), &last_updated, | 1393 thumbnail_db_->GetFavIcon(url_info.favicon_id(), &last_updated, |
1394 &data->data, &icon_url)) { | 1394 &data->data, &icon_url)) { |
1395 know_favicon = true; | 1395 know_favicon = true; |
1396 expired = (Time::Now() - last_updated) > | 1396 expired = (Time::Now() - last_updated) > |
1397 TimeDelta::FromDays(kFavIconRefetchDays); | 1397 TimeDelta::FromDays(kFavIconRefetchDays); |
1398 } | 1398 } |
1399 | 1399 |
1400 HISTOGRAM_TIMES(L"History.GetFavIconForURL", | 1400 HISTOGRAM_TIMES("History.GetFavIconForURL", |
1401 TimeTicks::Now() - beginning_time); | 1401 TimeTicks::Now() - beginning_time); |
1402 } | 1402 } |
1403 | 1403 |
1404 request->ForwardResult( | 1404 request->ForwardResult( |
1405 GetFavIconRequest::TupleType(request->handle(), know_favicon, data, | 1405 GetFavIconRequest::TupleType(request->handle(), know_favicon, data, |
1406 expired, icon_url)); | 1406 expired, icon_url)); |
1407 } | 1407 } |
1408 | 1408 |
1409 void HistoryBackend::SetFavIcon( | 1409 void HistoryBackend::SetFavIcon( |
1410 const GURL& page_url, | 1410 const GURL& page_url, |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1824 return true; | 1824 return true; |
1825 } | 1825 } |
1826 | 1826 |
1827 BookmarkService* HistoryBackend::GetBookmarkService() { | 1827 BookmarkService* HistoryBackend::GetBookmarkService() { |
1828 if (bookmark_service_) | 1828 if (bookmark_service_) |
1829 bookmark_service_->BlockTillLoaded(); | 1829 bookmark_service_->BlockTillLoaded(); |
1830 return bookmark_service_; | 1830 return bookmark_service_; |
1831 } | 1831 } |
1832 | 1832 |
1833 } // namespace history | 1833 } // namespace history |
1834 | |
OLD | NEW |