New issue
Advanced search Search tips

Issue 674165 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Jan 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: ----



Sign in to add a comment

WebHistoryService query end time not exclusive

Project Member Reported by twelling...@chromium.org, Dec 14 2016

Issue description

When querying browsing history, an "end_time" is passed in as a query option. This end time is supposed to be exclusive, according to the documentation in history_types.h: https://cs.chromium.org/chromium/src/components/history/core/browser/history_types.h?q=queryoptions+end_time&sq=package:chromium&dr=CSs&l=235

It appears that for the regular local HistoryService the end time is exclusive, but for the WebHistoryService the end time is inclusive.

Repro steps:
1) Make a query to BrowsingHistoryService with base::Time() for the end_time (match all results) and a max of X queries (e.g. X = 5)
2) Store the timestamp for the last history entry in C++
3) Issue another query to BrowsingHistoryService with the stored timestamp for the end_time and a max of X queries
4) repeat steps 2-3

Observed behavior: duplicate results from the WebHistoryService appear at the query boundary e.g. if google.com is the last result returned in the query for #1, it will be the first result returned for the query in #3.

Expected behavior: the end time is supposed to be exclusive

I suspect this is a non-regression issue that has been hidden by the fact that our history web ui converts the C++ timestamp to/from JavaScript time. JavaScript uses less bits to represent the number so some precision is lost e.g. rather than 13123713486001564, the conversion to/from JavaScript causes the end_time to be 13123713486001000. This effectively sets the end_time used for the next query to an earlier date and hides WebHistoryService's non-exclusive use of end_time.
 
In theory there could be a scenario where we show duplicate entries because a WebHistoryService visit has the perfect timestamp and is the last result returned for a query, but in practice I think it's very unlikely to occur.
Cc: twelling...@chromium.org
Owner: msramek@chromium.org
Status: Assigned (was: Untriaged)
Confirmed. Good catch!

We could fix the +/-1 errors and update the QueryOptions documentation to say that this behaves differently with local and web history, but I think it's cleaner to ask the serverside folks to use a half-closed interval. Those are not only used for time ranges all over Chrome, but, well, in computer science.
Filed b/33686503.
Status: Started (was: Assigned)
As discussed, the server is using closed intervals everywhere, and they don't want to make a one-off change for the API. Alright then, I'll fix this clientside.

Project Member

Comment 6 by bugdroid1@chromium.org, Jan 12 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/39f5b80c5358f69f8407557990beed449fa03e74

commit 39f5b80c5358f69f8407557990beed449fa03e74
Author: msramek <msramek@chromium.org>
Date: Thu Jan 12 16:07:14 2017

Fix the end time bound in WebHistoryService to match the API

Change the exclusive end time bound in WebHistoryService to be inclusive,
as required by the history.google.com API.

BUG= 674165 

Review-Url: https://codereview.chromium.org/2621143004
Cr-Commit-Position: refs/heads/master@{#443245}

[modify] https://crrev.com/39f5b80c5358f69f8407557990beed449fa03e74/components/history/core/browser/web_history_service.cc

Status: Fixed (was: Started)

Sign in to add a comment