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 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 if (!segment_queried_) { | 1078 if (!segment_queried_) { |
1079 segment_queried_ = true; | 1079 segment_queried_ = true; |
1080 base::MessageLoop::current()->PostTask( | 1080 base::MessageLoop::current()->PostTask( |
1081 FROM_HERE, | 1081 FROM_HERE, |
1082 base::Bind(&HistoryBackend::DeleteOldSegmentData, this)); | 1082 base::Bind(&HistoryBackend::DeleteOldSegmentData, this)); |
1083 } | 1083 } |
1084 } | 1084 } |
1085 request->ForwardResult(request->handle(), &request->value.get()); | 1085 request->ForwardResult(request->handle(), &request->value.get()); |
1086 } | 1086 } |
1087 | 1087 |
1088 void HistoryBackend::IncreaseSegmentDuration(const GURL& url, | |
1089 base::Time time, | |
1090 base::TimeDelta delta) { | |
1091 if (!db_) | |
1092 return; | |
1093 | |
1094 const std::string segment_name(VisitSegmentDatabase::ComputeSegmentName(url)); | |
1095 SegmentID segment_id = db_->GetSegmentNamed(segment_name); | |
1096 if (!segment_id) { | |
1097 URLID url_id = db_->GetRowForURL(url, NULL); | |
1098 if (!url_id) | |
1099 return; | |
1100 segment_id = db_->CreateSegment(url_id, segment_name); | |
1101 if (!segment_id) | |
1102 return; | |
1103 } | |
1104 SegmentDurationID duration_id; | |
1105 base::TimeDelta total_delta; | |
1106 if (!db_->GetSegmentDuration(segment_id, time, &duration_id, | |
1107 &total_delta)) { | |
1108 db_->CreateSegmentDuration(segment_id, time, delta); | |
1109 return; | |
1110 } | |
1111 total_delta += delta; | |
1112 db_->SetSegmentDuration(duration_id, total_delta); | |
1113 } | |
1114 | |
1115 void HistoryBackend::QuerySegmentDuration( | |
1116 scoped_refptr<QuerySegmentUsageRequest> request, | |
1117 const base::Time from_time, | |
1118 int max_result_count) { | |
1119 if (request->canceled()) | |
1120 return; | |
1121 | |
1122 if (db_) { | |
1123 db_->QuerySegmentDuration(from_time, max_result_count, | |
1124 &request->value.get()); | |
1125 } | |
1126 request->ForwardResult(request->handle(), &request->value.get()); | |
1127 } | |
1128 | |
1129 // Keyword visits -------------------------------------------------------------- | 1088 // Keyword visits -------------------------------------------------------------- |
1130 | 1089 |
1131 void HistoryBackend::SetKeywordSearchTermsForURL(const GURL& url, | 1090 void HistoryBackend::SetKeywordSearchTermsForURL(const GURL& url, |
1132 TemplateURLID keyword_id, | 1091 TemplateURLID keyword_id, |
1133 const base::string16& term) { | 1092 const base::string16& term) { |
1134 if (!db_) | 1093 if (!db_) |
1135 return; | 1094 return; |
1136 | 1095 |
1137 // Get the ID for this URL. | 1096 // Get the ID for this URL. |
1138 URLID url_id = db_->GetRowForURL(url, NULL); | 1097 URLID url_id = db_->GetRowForURL(url, NULL); |
(...skipping 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2968 int rank = kPageVisitStatsMaxTopSites; | 2927 int rank = kPageVisitStatsMaxTopSites; |
2969 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url); | 2928 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url); |
2970 if (it != most_visited_urls_map_.end()) | 2929 if (it != most_visited_urls_map_.end()) |
2971 rank = (*it).second; | 2930 rank = (*it).second; |
2972 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank", | 2931 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank", |
2973 rank, kPageVisitStatsMaxTopSites + 1); | 2932 rank, kPageVisitStatsMaxTopSites + 1); |
2974 } | 2933 } |
2975 #endif | 2934 #endif |
2976 | 2935 |
2977 } // namespace history | 2936 } // namespace history |
OLD | NEW |