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

Unified Diff: chrome/browser/history/visit_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/visit_database.h ('k') | chrome/browser/history/visitsegment_database.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/visit_database.cc
diff --git a/chrome/browser/history/visit_database.cc b/chrome/browser/history/visit_database.cc
index a72afb6ec1de8ee9c31f291110e3e268ffbbbed4..264fddbc0f9cd6b8642c384411d3ebb301ca6769 100644
--- a/chrome/browser/history/visit_database.cc
+++ b/chrome/browser/history/visit_database.cc
@@ -15,6 +15,7 @@
#include "base/string_number_conversions.h"
#include "base/timer.h"
#include "base/stl_util.h"
+#include "chrome/browser/history/time_filter.h"
#include "chrome/browser/history/url_database.h"
#include "chrome/common/url_constants.h"
#include "content/public/common/page_transition_types.h"
@@ -531,6 +532,46 @@ bool VisitDatabase::GetAllVisitsInRange(base::Time begin_time,
return FillVisitVector(statement, visits);
}
+bool VisitDatabase::GetAllVisitsDuringTimes(const TimeFilter& time_filter,
+ int max_results,
+ VisitVector* visits) {
+ visits->clear();
+ if (max_results)
+ visits->reserve(max_results);
+
+ for (TimeFilter::TimeVector::const_iterator it =
+ time_filter.get_times().begin();
+ it != time_filter.get_times().end(); ++it) {
+ sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
+ "SELECT" HISTORY_VISIT_ROW_FIELDS "FROM visits "
+ "WHERE visit_time >= ? AND visit_time < ?"
+ "ORDER BY visit_time LIMIT ?"));
+
+ // See GetVisibleVisitsInRange for more info on how these times are bound.
+ statement.BindInt64(0, it->first.ToInternalValue());
+ statement.BindInt64(1, it->second.is_null() ?
+ it->second.ToInternalValue() : std::numeric_limits<int64>::max());
+ statement.BindInt64(2,
+ max_results ? max_results : std::numeric_limits<int64>::max());
+
+ VisitVector v;
+ if (!FillVisitVector(statement, &v))
+ return false;
+ size_t take_only = 0;
+ if (max_results &&
+ static_cast<int>(visits->size() + v.size()) > max_results) {
+ take_only = max_results - visits->size();
+ }
+
+ visits->insert(visits->end(),
+ v.begin(), take_only ? v.begin() + take_only : v.end());
+ if (max_results && static_cast<int>(visits->size()) == max_results)
+ return true;
+ }
+ return true;
+}
+
+
bool VisitDatabase::GetVisitsInRangeForTransition(
base::Time begin_time,
base::Time end_time,
@@ -600,6 +641,31 @@ void VisitDatabase::GetVisibleVisitsInRange(base::Time begin_time,
}
}
+void VisitDatabase::GetVisibleVisitsDuringTimes(const TimeFilter& time_filter,
+ int max_results,
+ VisitVector* visits) {
+ visits->clear();
+ if (max_results)
+ visits->reserve(max_results);
+ for (TimeFilter::TimeVector::const_iterator it =
+ time_filter.get_times().begin();
+ it != time_filter.get_times().end(); ++it) {
+ VisitVector v;
+ GetVisibleVisitsInRange(it->first, it->second, max_results, &v);
+ size_t take_only = 0;
+ if (max_results &&
+ static_cast<int>(visits->size() + v.size()) > max_results) {
+ take_only = max_results - visits->size();
+ }
+
+ visits->insert(visits->end(),
+ v.begin(), take_only ? v.begin() + take_only : v.end());
+ if (max_results && static_cast<int>(visits->size()) == max_results)
+ return;
+ }
+}
+
+
VisitID VisitDatabase::GetMostRecentVisitForURL(URLID url_id,
VisitRow* visit_row) {
// The visit_time values can be duplicated in a redirect chain, so we sort
« no previous file with comments | « chrome/browser/history/visit_database.h ('k') | chrome/browser/history/visitsegment_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698