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

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

Issue 2752263003: Count site data size for important sites (Closed)
Patch Set: rebase Created 3 years, 7 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/macros.h" 11 #include "base/macros.h"
12 #include "url/gurl.h" 12 #include "url/gurl.h"
13 13
14 class Profile; 14 class Profile;
15 15
16 namespace user_prefs { 16 namespace user_prefs {
17 class PrefRegistrySyncable; 17 class PrefRegistrySyncable;
18 } 18 }
19 19
20 // Helper methods for important sites.
21 // All methods should be used on the UI thread.
20 class ImportantSitesUtil { 22 class ImportantSitesUtil {
21 public: 23 public:
24 #if defined(OS_ANDROID)
25 static const int kMaxImportantSites = 5;
26 #else
27 static const int kMaxImportantSites = 10;
28 #endif
29
22 struct ImportantDomainInfo { 30 struct ImportantDomainInfo {
23 std::string registerable_domain; 31 std::string registerable_domain;
24 GURL example_origin; 32 GURL example_origin;
25 double engagement_score = 0; 33 double engagement_score = 0;
26 int32_t reason_bitfield = 0; 34 int32_t reason_bitfield = 0;
35 // |usage| has to be initialized by ImportantSitesUsageCounter before it
36 // will contain the number of bytes used for quota and localstorage.
37 int64_t usage = 0;
27 }; 38 };
28 39
29 // Do not change the values here, as they are used for UMA histograms. 40 // Do not change the values here, as they are used for UMA histograms.
30 enum ImportantReason { 41 enum ImportantReason {
31 ENGAGEMENT = 0, 42 ENGAGEMENT = 0,
32 DURABLE = 1, 43 DURABLE = 1,
33 BOOKMARKS = 2, 44 BOOKMARKS = 2,
34 HOME_SCREEN = 3, 45 HOME_SCREEN = 3,
35 NOTIFICATIONS = 4, 46 NOTIFICATIONS = 4,
36 REASON_BOUNDARY 47 REASON_BOUNDARY
37 }; 48 };
38 49
50 static std::string GetRegisterableDomainOrIP(const GURL& url);
Bernhard Bauer 2017/05/04 14:16:45 Nit: "registrable" is far more common than "regist
dullweber 2017/05/05 08:35:28 "registerable" was already used everywhere in this
51
52 static std::string GetRegisterableDomainOrIPFromHost(base::StringPiece host);
53
39 static bool IsDialogDisabled(Profile* profile); 54 static bool IsDialogDisabled(Profile* profile);
40 55
41 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 56 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
42 57
43 // This returns the top |<=max_results| important registrable domains. This 58 // This returns the top |<=max_results| important registrable domains. This
44 // uses site engagement and notifications to generate the list. |max_results| 59 // uses site engagement and notifications to generate the list. |max_results|
45 // is assumed to be small. 60 // is assumed to be small.
46 // See net/base/registry_controlled_domains/registry_controlled_domain.h for 61 // See net/base/registry_controlled_domains/registry_controlled_domain.h for
47 // more details on registrable domains and the current list of effective 62 // more details on registrable domains and the current list of effective
48 // eTLDs. 63 // eTLDs.
(...skipping 18 matching lines...) Expand all
67 // the score requirements for the Site Engagement Service, so ONLY call for 82 // the score requirements for the Site Engagement Service, so ONLY call for
68 // testing. 83 // testing.
69 static void MarkOriginAsImportantForTesting(Profile* profile, 84 static void MarkOriginAsImportantForTesting(Profile* profile,
70 const GURL& origin); 85 const GURL& origin);
71 86
72 private: 87 private:
73 DISALLOW_IMPLICIT_CONSTRUCTORS(ImportantSitesUtil); 88 DISALLOW_IMPLICIT_CONSTRUCTORS(ImportantSitesUtil);
74 }; 89 };
75 90
76 #endif // CHROME_BROWSER_ENGAGEMENT_IMPORTANT_SITES_UTIL_H_ 91 #endif // CHROME_BROWSER_ENGAGEMENT_IMPORTANT_SITES_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698