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

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

Issue 1551503002: Convert Pass()→std::move() in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
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
9 #include <algorithm> 8 #include <algorithm>
10 #include <cmath> 9 #include <cmath>
10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/metrics/field_trial.h" 14 #include "base/metrics/field_trial.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/time/clock.h" 17 #include "base/time/clock.h"
18 #include "base/time/default_clock.h" 18 #include "base/time/default_clock.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 20 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // Delta within which to consider internal time values equal. Internal time 56 // Delta within which to consider internal time values equal. Internal time
57 // values are in microseconds, so this delta comes out at one second. 57 // values are in microseconds, so this delta comes out at one second.
58 const double kTimeDelta = 1000000; 58 const double kTimeDelta = 1000000;
59 59
60 scoped_ptr<ContentSettingsForOneType> GetEngagementContentSettings( 60 scoped_ptr<ContentSettingsForOneType> GetEngagementContentSettings(
61 HostContentSettingsMap* settings_map) { 61 HostContentSettingsMap* settings_map) {
62 scoped_ptr<ContentSettingsForOneType> engagement_settings( 62 scoped_ptr<ContentSettingsForOneType> engagement_settings(
63 new ContentSettingsForOneType); 63 new ContentSettingsForOneType);
64 settings_map->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, 64 settings_map->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT,
65 std::string(), engagement_settings.get()); 65 std::string(), engagement_settings.get());
66 return engagement_settings.Pass(); 66 return engagement_settings;
67 } 67 }
68 68
69 bool DoublesConsideredDifferent(double value1, double value2, double delta) { 69 bool DoublesConsideredDifferent(double value1, double value2, double delta) {
70 double abs_difference = fabs(value1 - value2); 70 double abs_difference = fabs(value1 - value2);
71 return abs_difference > delta; 71 return abs_difference > delta;
72 } 72 }
73 73
74 // Only accept a navigation event for engagement if it is one of: 74 // Only accept a navigation event for engagement if it is one of:
75 // a. direct typed navigation 75 // a. direct typed navigation
76 // b. clicking on an omnibox suggestion brought up by typing a keyword 76 // b. clicking on an omnibox suggestion brought up by typing a keyword
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 GetScoreDictForOrigin(settings_map, origin); 396 GetScoreDictForOrigin(settings_map, origin);
397 SiteEngagementScore score(clock_.get(), *score_dict); 397 SiteEngagementScore score(clock_.get(), *score_dict);
398 score_map[origin] = score.Score(); 398 score_map[origin] = score.Score();
399 } 399 }
400 400
401 return score_map; 401 return score_map;
402 } 402 }
403 403
404 SiteEngagementService::SiteEngagementService(Profile* profile, 404 SiteEngagementService::SiteEngagementService(Profile* profile,
405 scoped_ptr<base::Clock> clock) 405 scoped_ptr<base::Clock> clock)
406 : profile_(profile), clock_(clock.Pass()), weak_factory_(this) { 406 : profile_(profile), clock_(std::move(clock)), weak_factory_(this) {
407 // May be null in tests. 407 // May be null in tests.
408 history::HistoryService* history = HistoryServiceFactory::GetForProfile( 408 history::HistoryService* history = HistoryServiceFactory::GetForProfile(
409 profile, ServiceAccessType::IMPLICIT_ACCESS); 409 profile, ServiceAccessType::IMPLICIT_ACCESS);
410 if (history) 410 if (history)
411 history->AddObserver(this); 411 history->AddObserver(this);
412 } 412 }
413 413
414 void SiteEngagementService::AddPoints(const GURL& url, double points) { 414 void SiteEngagementService::AddPoints(const GURL& url, double points) {
415 HostContentSettingsMap* settings_map = 415 HostContentSettingsMap* settings_map =
416 HostContentSettingsMapFactory::GetForProfile(profile_); 416 HostContentSettingsMapFactory::GetForProfile(profile_);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 HostContentSettingsMapFactory::GetForProfile(profile_); 548 HostContentSettingsMapFactory::GetForProfile(profile_);
549 for (const auto& origin_to_count : origin_counts) { 549 for (const auto& origin_to_count : origin_counts) {
550 if (origin_to_count.second != 0) 550 if (origin_to_count.second != 0)
551 continue; 551 continue;
552 552
553 settings_map->SetWebsiteSettingDefaultScope( 553 settings_map->SetWebsiteSettingDefaultScope(
554 origin_to_count.first, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, 554 origin_to_count.first, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT,
555 std::string(), nullptr); 555 std::string(), nullptr);
556 } 556 }
557 } 557 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698