OLD | NEW |
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 content::BrowserThread::UI), | 115 content::BrowserThread::UI), |
116 base::Bind(&SiteEngagementService::AfterStartupTask, | 116 base::Bind(&SiteEngagementService::AfterStartupTask, |
117 weak_factory_.GetWeakPtr())); | 117 weak_factory_.GetWeakPtr())); |
118 | 118 |
119 if (!g_updated_from_variations) { | 119 if (!g_updated_from_variations) { |
120 SiteEngagementScore::UpdateFromVariations(kEngagementParams); | 120 SiteEngagementScore::UpdateFromVariations(kEngagementParams); |
121 g_updated_from_variations = true; | 121 g_updated_from_variations = true; |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 SiteEngagementService::~SiteEngagementService() { | 125 SiteEngagementService::~SiteEngagementService() = default; |
| 126 |
| 127 void SiteEngagementService::Shutdown() { |
126 history::HistoryService* history = HistoryServiceFactory::GetForProfile( | 128 history::HistoryService* history = HistoryServiceFactory::GetForProfile( |
127 profile_, ServiceAccessType::IMPLICIT_ACCESS); | 129 profile_, ServiceAccessType::IMPLICIT_ACCESS); |
128 if (history) | 130 if (history) |
129 history->RemoveObserver(this); | 131 history->RemoveObserver(this); |
130 } | 132 } |
131 | 133 |
132 blink::mojom::EngagementLevel | 134 blink::mojom::EngagementLevel |
133 SiteEngagementService::GetEngagementLevel(const GURL& url) const { | 135 SiteEngagementService::GetEngagementLevel(const GURL& url) const { |
134 if (IsLastEngagementStale()) | 136 if (IsLastEngagementStale()) |
135 CleanupEngagementScores(true); | 137 CleanupEngagementScores(true); |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 if (!engagement_score.last_shortcut_launch_time().is_null() && | 650 if (!engagement_score.last_shortcut_launch_time().is_null() && |
649 engagement_score.last_shortcut_launch_time() > last_visit) { | 651 engagement_score.last_shortcut_launch_time() > last_visit) { |
650 engagement_score.set_last_shortcut_launch_time(last_visit); | 652 engagement_score.set_last_shortcut_launch_time(last_visit); |
651 } | 653 } |
652 | 654 |
653 engagement_score.Commit(); | 655 engagement_score.Commit(); |
654 } | 656 } |
655 | 657 |
656 SetLastEngagementTime(now); | 658 SetLastEngagementTime(now); |
657 } | 659 } |
OLD | NEW |