Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5402)

Unified Diff: chrome/browser/history/visitsegment_database.cc

Issue 9358073: First version of the time slicing on the urls. Not ready for review yet. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added relative time to time slicing Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/history/visitsegment_database.h ('k') | chrome/browser/resources/ntp4/new_tab.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/visitsegment_database.cc
diff --git a/chrome/browser/history/visitsegment_database.cc b/chrome/browser/history/visitsegment_database.cc
index 98e782785f73ddb883441129ce16e80feb1f7ecf..ecb272763b15fd9636233007fc43250fae5ab841 100644
--- a/chrome/browser/history/visitsegment_database.cc
+++ b/chrome/browser/history/visitsegment_database.cc
@@ -217,6 +217,14 @@ void VisitSegmentDatabase::QuerySegmentUsage(
base::Time from_time,
int max_result_count,
std::vector<PageUsageData*>* results) {
+ QuerySegmentUsageTimeInterval(from_time, base::Time(), max_result_count,
+ results);
+}
+void VisitSegmentDatabase::QuerySegmentUsageTimeInterval(
+ base::Time from_time,
+ base::Time to_time,
+ int max_result_count,
+ std::vector<PageUsageData*>* results) {
// This function gathers the highest-ranked segments in two queries.
// The first gathers scores for all segments.
// The second gathers segment data (url, title, etc.) for the highest-ranked
@@ -226,15 +234,25 @@ void VisitSegmentDatabase::QuerySegmentUsage(
// does as well.
// Gather all the segment scores.
- sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
- "SELECT segment_id, time_slot, visit_count "
- "FROM segment_usage WHERE time_slot >= ? "
- "ORDER BY segment_id"));
+ sql::Statement statement;
+ if (to_time.is_null()) {
+ statement.Assign(GetDB().GetCachedStatement(SQL_FROM_HERE,
+ "SELECT segment_id, time_slot, visit_count "
+ "FROM segment_usage WHERE time_slot >= ? "
+ "ORDER BY segment_id"));
+ } else {
+ statement.Assign(GetDB().GetCachedStatement(SQL_FROM_HERE,
+ "SELECT segment_id, time_slot, visit_count "
+ "FROM segment_usage WHERE time_slot >= ? AND time_slot <= ?"
+ "ORDER BY segment_id"));
+ }
if (!statement.is_valid())
return;
- base::Time ts = from_time.LocalMidnight();
+ base::Time ts = (to_time.is_null()) ? from_time.LocalMidnight() : from_time;
statement.BindInt64(0, ts.ToInternalValue());
+ if (!to_time.is_null())
+ statement.BindInt64(1, to_time.ToInternalValue());
base::Time now = base::Time::Now();
SegmentID last_segment_id = 0;
« no previous file with comments | « chrome/browser/history/visitsegment_database.h ('k') | chrome/browser/resources/ntp4/new_tab.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698