New issue
Advanced search Search tips

Issue 604305 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Aug 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

Refactor SiteEngagementScore so that all methods accept a base::Time instead of the constructor taking a base::Clock

Project Member Reported by dominickn@chromium.org, Apr 18 2016

Issue description

Privacy's re-review of site engagement has led to the need for the site engagement service to be able to adjust the last updated and last shortcut times for each origin.

As it is currently implemented, SiteEngagementScore takes a base::Clock and uses that clock to generate times. However, the Reset() method must now take a base::Time* for the purposes of resetting the time when requested.

This would be cleaner if the clock was removed from SiteEngagementScore, and a base::Time provided to all methods to be used to calculating times.
 
Status: Assigned (was: Untriaged)
I'm not sure why this is better. I'd prefer to pass the clock in once at construction rather than passing clock->Now() at every Score(), AddPoints() and MaxPointsPerDayAdded().

To avoid the nastiness of passing a nullptr Time, we can just call clock_->Now() for that one case since it makes sense to say the caller of Reset must specify the new last access time.
The primary reason is that SiteEngagementScore is an implementation detail that's almost always used like this:
  // Create score (passes in clock)
  // Call a single method on score
  // Return
Only in testing are multiple methods called on the same score repeatedly, so the change basically moves passing in the clock on construction to passing in clock->Now on the single method that's called. Given that, it seems a bit strange to pass in the clock; the site engagement service is in charge of times, and the score just does what it's told.

The subtlety with Reset() is that it needs to *not* reset the last shortcut launch time in most cases, except in the case when history is being cleared. That means calling it with clock->Now() is incorrect; you don't want to set the last shortcut launch time to Now(). We could either duplicate a bunch of the reset code for the history clearing case, or pass in the null time.
How do you feel about this: https://codereview.chromium.org/1919383005/ ?

It centralizes the clock passing, removes all the update duplication and moves the shortcut time setting logic into the SiteEngagementService (it was weird for the SiteEngagementScore to decide that the score shouldn't get set in certain cases).
Project Member

Comment 5 by sheriffbot@chromium.org, Jun 1 2016

Labels: -M-52 M-53 MovedFrom-52
Moving this nonessential bug to the next milestone.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Project Member

Comment 6 by sheriffbot@chromium.org, Jul 13 2016

Labels: -M-53 MovedFrom-53
This issue has been moved once and is lower than Pri-1. Removing the milestone.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Status: Fixed (was: Assigned)
Components: -Security>UX
Labels: Team-Security-UX
Security>UX component is deprecated in favor of the Team-Security-UX label

Sign in to add a comment