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

Unified Diff: components/history/core/browser/visit_database.cc

Issue 1143183002: Proof of concept implementation of context based history filtering. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « components/history/core/browser/visit_database.h ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/history/core/browser/visit_database.cc
diff --git a/components/history/core/browser/visit_database.cc b/components/history/core/browser/visit_database.cc
index 6d5819c36621ae11058b478811aaca64af2736e8..0761e1138b40012d1ad9f44230a3c27a6855bd50 100644
--- a/components/history/core/browser/visit_database.cc
+++ b/components/history/core/browser/visit_database.cc
@@ -36,7 +36,8 @@ bool VisitDatabase::InitVisitTable() {
"segment_id INTEGER,"
// Some old DBs may have an "is_indexed" field here, but this is no
// longer used and should NOT be read or written from any longer.
- "visit_duration INTEGER DEFAULT 0 NOT NULL)"))
+ "visit_duration INTEGER DEFAULT 0 NOT NULL,"
+ "context INTEGER DEFAULT 0 NOT NULL)"))
return false;
}
@@ -91,6 +92,7 @@ void VisitDatabase::FillVisitRow(sql::Statement& statement, VisitRow* visit) {
visit->segment_id = statement.ColumnInt64(5);
visit->visit_duration =
base::TimeDelta::FromInternalValue(statement.ColumnInt64(6));
+ visit->context = static_cast<HistoryContext>(statement.ColumnInt(7));
}
// static
@@ -145,20 +147,20 @@ VisitID VisitDatabase::AddVisit(VisitRow* visit, VisitSource source) {
sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
"INSERT INTO visits "
"(url, visit_time, from_visit, transition, segment_id, "
- "visit_duration) VALUES (?,?,?,?,?,?)"));
+ "visit_duration, context) VALUES (?,?,?,?,?,?,?)"));
statement.BindInt64(0, visit->url_id);
statement.BindInt64(1, visit->visit_time.ToInternalValue());
statement.BindInt64(2, visit->referring_visit);
statement.BindInt64(3, visit->transition);
statement.BindInt64(4, visit->segment_id);
statement.BindInt64(5, visit->visit_duration.ToInternalValue());
+ statement.BindInt(6, static_cast<int>(visit->context));
if (!statement.Run()) {
DVLOG(0) << "Failed to execute visit insert statement: "
<< "url_id = " << visit->url_id;
return 0;
}
-
visit->visit_id = GetDB().GetLastInsertRowId();
if (source != SOURCE_BROWSED) {
@@ -231,14 +233,15 @@ bool VisitDatabase::UpdateVisitRow(const VisitRow& visit) {
sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
"UPDATE visits SET "
"url=?,visit_time=?,from_visit=?,transition=?,segment_id=?,"
- "visit_duration=? WHERE id=?"));
+ "visit_duration=?, context=? WHERE id=?"));
statement.BindInt64(0, visit.url_id);
statement.BindInt64(1, visit.visit_time.ToInternalValue());
statement.BindInt64(2, visit.referring_visit);
statement.BindInt64(3, visit.transition);
statement.BindInt64(4, visit.segment_id);
statement.BindInt64(5, visit.visit_duration.ToInternalValue());
- statement.BindInt64(6, visit.visit_id);
+ statement.BindInt(6, visit.context);
+ statement.BindInt64(7, visit.visit_id);
return statement.Run();
}
@@ -351,6 +354,7 @@ bool VisitDatabase::GetVisibleVisitsInRange(const QueryOptions& options,
visits->clear();
// The visit_time values can be duplicated in a redirect chain, so we sort
// by id too, to ensure a consistent ordering just in case.
+ if (static_cast<int>(options.context) < 1 || static_cast<int>(options.context) > 5) {
sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
"SELECT" HISTORY_VISIT_ROW_FIELDS "FROM visits "
"WHERE visit_time >= ? AND visit_time < ? "
@@ -358,7 +362,6 @@ bool VisitDatabase::GetVisibleVisitsInRange(const QueryOptions& options,
"AND (transition & ?) NOT IN (?, ?, ?) " // NO SUBFRAME or
// KEYWORD_GENERATED
"ORDER BY visit_time DESC, id DESC"));
-
statement.BindInt64(0, options.EffectiveBeginTime());
statement.BindInt64(1, options.EffectiveEndTime());
statement.BindInt(2, ui::PAGE_TRANSITION_CHAIN_END);
@@ -366,8 +369,25 @@ bool VisitDatabase::GetVisibleVisitsInRange(const QueryOptions& options,
statement.BindInt(4, ui::PAGE_TRANSITION_AUTO_SUBFRAME);
statement.BindInt(5, ui::PAGE_TRANSITION_MANUAL_SUBFRAME);
statement.BindInt(6, ui::PAGE_TRANSITION_KEYWORD_GENERATED);
-
return FillVisitVectorWithOptions(statement, options, visits);
+} else {
+ sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
+ "SELECT" HISTORY_VISIT_ROW_FIELDS "FROM visits "
+ "WHERE visit_time >= ? AND visit_time < ? AND context == ? "
+ "AND (transition & ?) != 0 " // CHAIN_END
+ "AND (transition & ?) NOT IN (?, ?, ?) " // NO SUBFRAME or
+ // KEYWORD_GENERATED
+ "ORDER BY visit_time DESC, id DESC"));
+ statement.BindInt64(0, options.EffectiveBeginTime());
+ statement.BindInt64(1, options.EffectiveEndTime());
+ statement.BindInt(2, static_cast<int>(options.context));
+ statement.BindInt(3, ui::PAGE_TRANSITION_CHAIN_END);
+ statement.BindInt(4, ui::PAGE_TRANSITION_CORE_MASK);
+ statement.BindInt(5, ui::PAGE_TRANSITION_AUTO_SUBFRAME);
+ statement.BindInt(6, ui::PAGE_TRANSITION_MANUAL_SUBFRAME);
+ statement.BindInt(7, ui::PAGE_TRANSITION_KEYWORD_GENERATED);
+ return FillVisitVectorWithOptions(statement, options, visits);
+}
}
void VisitDatabase::GetDirectVisitsDuringTimes(const VisitFilter& time_filter,
« no previous file with comments | « components/history/core/browser/visit_database.h ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698