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

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

Issue 9789001: Changes to add duration into history database. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added a column in visits db instead of a new table Created 8 years, 9 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
Index: chrome/browser/history/history_backend.cc
diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc
index cb8efa32bc6bfa694d3d4a712a0c86bb3bc5fb5c..c874c49a0872c7fe803132a0481a13b926d4e413 100644
--- a/chrome/browser/history/history_backend.cc
+++ b/chrome/browser/history/history_backend.cc
@@ -367,6 +367,29 @@ SegmentID HistoryBackend::UpdateSegments(
return segment_id;
}
+void HistoryBackend::UpdateDBWithPageInfo(const void* host,
+ int32 page_id,
+ const GURL& url,
+ const Time end_ts) {
+ // Will be filled with the URL ID and the visit ID of the last addition.
+ VisitID visit_id = tracker_.GetLastVisit(host, page_id, url);
+ UpdateVisitDuration(visit_id, end_ts);
+}
+
+void HistoryBackend::UpdateVisitDuration(VisitID visit_id, const Time end_ts) {
+ if (!db_.get())
+ return;
+
+ // Get the starting visit_time for visit_id.
+ VisitRow visit_row;
+ if (db_->GetRowForVisit(visit_id, &visit_row)) {
+ // We should never have a negative duration time even when time is skewed.
+ visit_row.visit_duration = end_ts > visit_row.visit_time ?
+ end_ts - visit_row.visit_time : TimeDelta::FromMicroseconds(0);
+ db_->UpdateVisitRow(visit_row);
+ }
+}
+
void HistoryBackend::AddPage(scoped_refptr<HistoryAddPageArgs> request) {
if (!db_.get())
return;
@@ -441,6 +464,9 @@ void HistoryBackend::AddPage(scoped_refptr<HistoryAddPageArgs> request) {
if (!is_keyword_generated) {
UpdateSegments(request->url, from_visit_id, last_ids.second, t,
last_recorded_time_);
+
+ // Update the referrer's duration.
+ UpdateVisitDuration(from_visit_id, last_recorded_time_);
}
} else {
// Redirect case. Add the redirect chain.
@@ -510,6 +536,9 @@ void HistoryBackend::AddPage(scoped_refptr<HistoryAddPageArgs> request) {
// Update the segment for this visit.
UpdateSegments(request->redirects[redirect_index],
from_visit_id, last_ids.second, t, last_recorded_time_);
+
+ // Update the visit_details for this visit.
+ UpdateVisitDuration(from_visit_id, last_recorded_time_);
}
// Subsequent transitions in the redirect list must all be sever

Powered by Google App Engine
This is Rietveld 408576698