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

Side by Side Diff: chrome/browser/engagement/important_sites_util.h

Issue 2752263003: Count site data size for important sites (Closed)
Patch Set: add localstorage to test case Created 3 years, 9 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 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 #ifndef CHROME_BROWSER_ENGAGEMENT_IMPORTANT_SITES_UTIL_H_ 5 #ifndef CHROME_BROWSER_ENGAGEMENT_IMPORTANT_SITES_UTIL_H_
6 #define CHROME_BROWSER_ENGAGEMENT_IMPORTANT_SITES_UTIL_H_ 6 #define CHROME_BROWSER_ENGAGEMENT_IMPORTANT_SITES_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "url/gurl.h" 13 #include "url/gurl.h"
13 14
14 class Profile; 15 class Profile;
15 16
17 namespace content {
18 class DOMStorageContext;
19 }
20
21 namespace storage {
22 class QuotaManager;
23 }
24
16 namespace user_prefs { 25 namespace user_prefs {
17 class PrefRegistrySyncable; 26 class PrefRegistrySyncable;
18 } 27 }
19 28
20 class ImportantSitesUtil { 29 class ImportantSitesUtil {
21 public: 30 public:
22 struct ImportantDomainInfo { 31 struct ImportantDomainInfo {
23 std::string registerable_domain; 32 std::string registerable_domain;
24 GURL example_origin; 33 GURL example_origin;
25 double engagement_score = 0; 34 double engagement_score = 0;
26 int32_t reason_bitfield = 0; 35 int32_t reason_bitfield = 0;
36 int64_t usage = 0;
27 }; 37 };
28 38
29 // Do not change the values here, as they are used for UMA histograms. 39 // Do not change the values here, as they are used for UMA histograms.
30 enum ImportantReason { 40 enum ImportantReason {
31 ENGAGEMENT = 0, 41 ENGAGEMENT = 0,
32 DURABLE = 1, 42 DURABLE = 1,
33 BOOKMARKS = 2, 43 BOOKMARKS = 2,
34 HOME_SCREEN = 3, 44 HOME_SCREEN = 3,
35 NOTIFICATIONS = 4, 45 NOTIFICATIONS = 4,
36 REASON_BOUNDARY 46 REASON_BOUNDARY
37 }; 47 };
38 48
49 using UsageCallback =
50 base::Callback<void(std::vector<ImportantDomainInfo> sites)>;
51
39 static bool IsDialogDisabled(Profile* profile); 52 static bool IsDialogDisabled(Profile* profile);
40 53
41 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 54 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
42 55
43 // This returns the top |<=max_results| important registrable domains. This 56 // This returns the top |<=max_results| important registrable domains. This
44 // uses site engagement and notifications to generate the list. |max_results| 57 // uses site engagement and notifications to generate the list. |max_results|
45 // is assumed to be small. 58 // is assumed to be small.
46 // See net/base/registry_controlled_domains/registry_controlled_domain.h for 59 // See net/base/registry_controlled_domains/registry_controlled_domain.h for
47 // more details on registrable domains and the current list of effective 60 // more details on registrable domains and the current list of effective
48 // eTLDs. 61 // eTLDs.
49 static std::vector<ImportantDomainInfo> GetImportantRegisterableDomains( 62 static std::vector<ImportantDomainInfo> GetImportantRegisterableDomains(
50 Profile* profile, 63 Profile* profile,
51 size_t max_results); 64 size_t max_results);
52 65
66 // Populate the ImportantDomainInfo::usage field of each site with the amount
67 // of storage bytes used. The |sites| vector with populated usage fields is
68 // returned by |callback|.
69 static void PopulateUsage(storage::QuotaManager* quota_manager,
dmurph 2017/03/27 22:22:45 Can you document threading expectations? I guess t
dullweber 2017/03/28 14:06:45 I checked the other methods and it looks like all
70 content::DOMStorageContext* dom_storage,
71 std::vector<ImportantDomainInfo> sites,
72 UsageCallback callback);
73
53 // Record the sites that the user chose to blacklist from clearing (in the 74 // Record the sites that the user chose to blacklist from clearing (in the
54 // Clear Browsing Dialog) and the sites they ignored. The blacklisted sites 75 // Clear Browsing Dialog) and the sites they ignored. The blacklisted sites
55 // are NOT cleared as they are 'blacklisted' from the clear operation. 76 // are NOT cleared as they are 'blacklisted' from the clear operation.
56 // This records metrics for blacklisted and ignored sites and removes any 77 // This records metrics for blacklisted and ignored sites and removes any
57 // 'ignored' sites from our important sites list if they were ignored 3 times 78 // 'ignored' sites from our important sites list if they were ignored 3 times
58 // in a row. 79 // in a row.
59 static void RecordBlacklistedAndIgnoredImportantSites( 80 static void RecordBlacklistedAndIgnoredImportantSites(
60 Profile* profile, 81 Profile* profile,
61 const std::vector<std::string>& blacklisted_sites, 82 const std::vector<std::string>& blacklisted_sites,
62 const std::vector<int32_t>& blacklisted_sites_reason_bitfield, 83 const std::vector<int32_t>& blacklisted_sites_reason_bitfield,
63 const std::vector<std::string>& ignored_sites, 84 const std::vector<std::string>& ignored_sites,
64 const std::vector<int32_t>& ignored_sites_reason_bitfield); 85 const std::vector<int32_t>& ignored_sites_reason_bitfield);
65 86
66 // This marks the given origin as important for testing. Note: This changes 87 // This marks the given origin as important for testing. Note: This changes
67 // the score requirements for the Site Engagement Service, so ONLY call for 88 // the score requirements for the Site Engagement Service, so ONLY call for
68 // testing. 89 // testing.
69 static void MarkOriginAsImportantForTesting(Profile* profile, 90 static void MarkOriginAsImportantForTesting(Profile* profile,
70 const GURL& origin); 91 const GURL& origin);
71 92
72 private: 93 private:
73 DISALLOW_IMPLICIT_CONSTRUCTORS(ImportantSitesUtil); 94 DISALLOW_IMPLICIT_CONSTRUCTORS(ImportantSitesUtil);
74 }; 95 };
75 96
76 #endif // CHROME_BROWSER_ENGAGEMENT_IMPORTANT_SITES_UTIL_H_ 97 #endif // CHROME_BROWSER_ENGAGEMENT_IMPORTANT_SITES_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/engagement/important_sites_util.cc » ('j') | chrome/browser/engagement/important_sites_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698