| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/important_sites_util.h" | 5 #include "chrome/browser/engagement/important_sites_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 static const int kTimesIgnoredForBlacklist = 3; | 49 static const int kTimesIgnoredForBlacklist = 3; |
| 50 | 50 |
| 51 // These are the maximum # of bookmarks we can use as signals. If the user has | 51 // These are the maximum # of bookmarks we can use as signals. If the user has |
| 52 // <= kMaxBookmarks, then we just use those bookmarks. Otherwise we filter all | 52 // <= kMaxBookmarks, then we just use those bookmarks. Otherwise we filter all |
| 53 // bookmarks on site engagement > 0, sort, and trim to kMaxBookmarks. | 53 // bookmarks on site engagement > 0, sort, and trim to kMaxBookmarks. |
| 54 static const int kMaxBookmarks = 5; | 54 static const int kMaxBookmarks = 5; |
| 55 | 55 |
| 56 // We need this to be a macro, as the histogram macros cache their pointers | 56 // We need this to be a macro, as the histogram macros cache their pointers |
| 57 // after the first call, so when we change the uma name we check fail if we're | 57 // after the first call, so when we change the uma name we check fail if we're |
| 58 // just a method. | 58 // just a method. |
| 59 #define RECORD_UMA_FOR_IMPORTANT_REASON(uma_name, uma_count_name, \ | 59 #define RECORD_UMA_FOR_IMPORTANT_REASON(uma_name, uma_count_name, \ |
| 60 reason_bitfield) \ | 60 reason_bitfield) \ |
| 61 do { \ | 61 do { \ |
| 62 int count = 0; \ | 62 int count = 0; \ |
| 63 int32_t bitfield = (reason_bitfield); \ | 63 int32_t bitfield = (reason_bitfield); \ |
| 64 for (int i = 0; i < ImportantReason::REASON_BOUNDARY; i++) { \ | 64 for (int i = 0; i < ImportantReason::REASON_BOUNDARY; i++) { \ |
| 65 if ((bitfield >> i) & 1) { \ | 65 if ((bitfield >> i) & 1) { \ |
| 66 count++; \ | 66 count++; \ |
| 67 UMA_HISTOGRAM_ENUMERATION((uma_name), i, \ | 67 UMA_HISTOGRAM_ENUMERATION((uma_name), static_cast<ImportantReason>(i), \ |
| 68 ImportantReason::REASON_BOUNDARY); \ | 68 ImportantReason::REASON_BOUNDARY); \ |
| 69 } \ | 69 } \ |
| 70 } \ | 70 } \ |
| 71 UMA_HISTOGRAM_ENUMERATION((uma_count_name), count, \ | 71 UMA_HISTOGRAM_EXACT_LINEAR( \ |
| 72 ImportantReason::REASON_BOUNDARY); \ | 72 (uma_count_name), count, \ |
| 73 static_cast<int>(ImportantReason::REASON_BOUNDARY)); \ |
| 73 } while (0) | 74 } while (0) |
| 74 | 75 |
| 75 // Do not change the values here, as they are used for UMA histograms and | 76 // Do not change the values here, as they are used for UMA histograms and |
| 76 // testing in important_sites_util_unittest. | 77 // testing in important_sites_util_unittest. |
| 77 enum CrossedReason { | 78 enum CrossedReason { |
| 78 CROSSED_DURABLE = 0, | 79 CROSSED_DURABLE = 0, |
| 79 CROSSED_NOTIFICATIONS = 1, | 80 CROSSED_NOTIFICATIONS = 1, |
| 80 CROSSED_ENGAGEMENT = 2, | 81 CROSSED_ENGAGEMENT = 2, |
| 81 CROSSED_NOTIFICATIONS_AND_ENGAGEMENT = 3, | 82 CROSSED_NOTIFICATIONS_AND_ENGAGEMENT = 3, |
| 82 CROSSED_DURABLE_AND_ENGAGEMENT = 4, | 83 CROSSED_DURABLE_AND_ENGAGEMENT = 4, |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 const GURL& origin) { | 487 const GURL& origin) { |
| 487 SiteEngagementScore::SetParamValuesForTesting(); | 488 SiteEngagementScore::SetParamValuesForTesting(); |
| 488 // First get data from site engagement. | 489 // First get data from site engagement. |
| 489 SiteEngagementService* site_engagement_service = | 490 SiteEngagementService* site_engagement_service = |
| 490 SiteEngagementService::Get(profile); | 491 SiteEngagementService::Get(profile); |
| 491 site_engagement_service->ResetBaseScoreForURL( | 492 site_engagement_service->ResetBaseScoreForURL( |
| 492 origin, SiteEngagementScore::GetMediumEngagementBoundary()); | 493 origin, SiteEngagementScore::GetMediumEngagementBoundary()); |
| 493 DCHECK(site_engagement_service->IsEngagementAtLeast( | 494 DCHECK(site_engagement_service->IsEngagementAtLeast( |
| 494 origin, blink::mojom::EngagementLevel::MEDIUM)); | 495 origin, blink::mojom::EngagementLevel::MEDIUM)); |
| 495 } | 496 } |
| OLD | NEW |