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

Side by Side Diff: chrome/browser/engagement/site_engagement_service.cc

Issue 2293793002: Make Site Engagement behave for adding 0 points. (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/engagement/site_engagement_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/engagement/site_engagement_service.h" 5 #include "chrome/browser/engagement/site_engagement_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 std::unique_ptr<base::Clock> clock) 258 std::unique_ptr<base::Clock> clock)
259 : profile_(profile), clock_(std::move(clock)), weak_factory_(this) { 259 : profile_(profile), clock_(std::move(clock)), weak_factory_(this) {
260 // May be null in tests. 260 // May be null in tests.
261 history::HistoryService* history = HistoryServiceFactory::GetForProfile( 261 history::HistoryService* history = HistoryServiceFactory::GetForProfile(
262 profile, ServiceAccessType::IMPLICIT_ACCESS); 262 profile, ServiceAccessType::IMPLICIT_ACCESS);
263 if (history) 263 if (history)
264 history->AddObserver(this); 264 history->AddObserver(this);
265 } 265 }
266 266
267 void SiteEngagementService::AddPoints(const GURL& url, double points) { 267 void SiteEngagementService::AddPoints(const GURL& url, double points) {
268 if (points == 0)
269 return;
270
268 // Trigger a cleanup and date adjustment if it has been a substantial length 271 // Trigger a cleanup and date adjustment if it has been a substantial length
269 // of time since *any* engagement was recorded by the service. This will 272 // of time since *any* engagement was recorded by the service. This will
270 // ensure that we do not decay scores when the user did not use the browser. 273 // ensure that we do not decay scores when the user did not use the browser.
271 if (IsLastEngagementStale()) 274 if (IsLastEngagementStale())
272 CleanupEngagementScores(true); 275 CleanupEngagementScores(true);
273 276
274 SiteEngagementScore score = CreateEngagementScore(url); 277 SiteEngagementScore score = CreateEngagementScore(url);
275 score.AddPoints(points); 278 score.AddPoints(points);
276 score.Commit(); 279 score.Commit();
277 280
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 if (!engagement_score.last_shortcut_launch_time().is_null() && 600 if (!engagement_score.last_shortcut_launch_time().is_null() &&
598 engagement_score.last_shortcut_launch_time() > last_visit) { 601 engagement_score.last_shortcut_launch_time() > last_visit) {
599 engagement_score.set_last_shortcut_launch_time(last_visit); 602 engagement_score.set_last_shortcut_launch_time(last_visit);
600 } 603 }
601 604
602 engagement_score.Commit(); 605 engagement_score.Commit();
603 } 606 }
604 607
605 SetLastEngagementTime(now); 608 SetLastEngagementTime(now);
606 } 609 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/engagement/site_engagement_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698