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

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: 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..198106cbf509098d888e1ab849ff55cf061ba1d2 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::UpdatePageInfo(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);
+ UpdateVisitDetails(visit_id, end_ts);
+}
+
+void HistoryBackend::UpdateVisitDetails(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.
+ TimeDelta duration = end_ts > visit_row.visit_time ?
+ end_ts - visit_row.visit_time : TimeDelta::FromMicroseconds(0);
+ db_->UpdateVisitDetails(visit_id, duration);
+ }
+}
+
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.
+ UpdateVisitDetails(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.
+ UpdateVisitDetails(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