| 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/history_backend.h" | 5 #include "chrome/browser/history/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 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 db_->GetVisitsSource(visits, sources); | 983 db_->GetVisitsSource(visits, sources); |
| 984 return true; | 984 return true; |
| 985 } | 985 } |
| 986 | 986 |
| 987 bool HistoryBackend::GetURL(const GURL& url, history::URLRow* url_row) { | 987 bool HistoryBackend::GetURL(const GURL& url, history::URLRow* url_row) { |
| 988 if (db_) | 988 if (db_) |
| 989 return db_->GetRowForURL(url, url_row) != 0; | 989 return db_->GetRowForURL(url, url_row) != 0; |
| 990 return false; | 990 return false; |
| 991 } | 991 } |
| 992 | 992 |
| 993 void HistoryBackend::QueryURL(scoped_refptr<QueryURLRequest> request, | 993 void HistoryBackend::QueryURL(const GURL& url, |
| 994 const GURL& url, | 994 bool want_visits, |
| 995 bool want_visits) { | 995 bool* success, |
| 996 if (request->canceled()) | 996 URLRow* url_row, |
| 997 return; | 997 VisitVector* visits) { |
| 998 | 998 DCHECK(success); |
| 999 bool success = false; | 999 DCHECK(url_row); |
| 1000 URLRow* row = &request->value.a; | 1000 DCHECK(!want_visits || visits); |
| 1001 VisitVector* visits = &request->value.b; | 1001 if ((*success = db_ && db_->GetRowForURL(url, url_row))) { |
| 1002 if (db_) { | 1002 // Optionally query the visits. |
| 1003 if (db_->GetRowForURL(url, row)) { | 1003 if (want_visits) { |
| 1004 // Have a row. | 1004 db_->GetVisitsForURL(url_row->id(), visits); |
| 1005 success = true; | |
| 1006 | |
| 1007 // Optionally query the visits. | |
| 1008 if (want_visits) | |
| 1009 db_->GetVisitsForURL(row->id(), visits); | |
| 1010 } | 1005 } |
| 1011 } | 1006 } |
| 1012 request->ForwardResult(request->handle(), success, row, visits); | |
| 1013 } | 1007 } |
| 1014 | 1008 |
| 1015 TypedUrlSyncableService* HistoryBackend::GetTypedUrlSyncableService() const { | 1009 TypedUrlSyncableService* HistoryBackend::GetTypedUrlSyncableService() const { |
| 1016 return typed_url_syncable_service_.get(); | 1010 return typed_url_syncable_service_.get(); |
| 1017 } | 1011 } |
| 1018 | 1012 |
| 1019 // Segment usage --------------------------------------------------------------- | 1013 // Segment usage --------------------------------------------------------------- |
| 1020 | 1014 |
| 1021 void HistoryBackend::DeleteOldSegmentData() { | 1015 void HistoryBackend::DeleteOldSegmentData() { |
| 1022 if (db_) | 1016 if (db_) |
| (...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2848 int rank = kPageVisitStatsMaxTopSites; | 2842 int rank = kPageVisitStatsMaxTopSites; |
| 2849 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url); | 2843 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url); |
| 2850 if (it != most_visited_urls_map_.end()) | 2844 if (it != most_visited_urls_map_.end()) |
| 2851 rank = (*it).second; | 2845 rank = (*it).second; |
| 2852 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank", | 2846 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank", |
| 2853 rank, kPageVisitStatsMaxTopSites + 1); | 2847 rank, kPageVisitStatsMaxTopSites + 1); |
| 2854 } | 2848 } |
| 2855 #endif | 2849 #endif |
| 2856 | 2850 |
| 2857 } // namespace history | 2851 } // namespace history |
| OLD | NEW |