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

Side by Side Diff: chrome/browser/safe_browsing/permission_reporter.h

Issue 2675483002: Replace PermissionType in chrome/ with ContentSettingsType (Closed)
Patch Set: ready Created 3 years, 10 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_SAFE_BROWSING_PERMISSION_REPORTER_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 #include <unordered_map> 10 #include <unordered_map>
11 11
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "chrome/browser/permissions/permission_uma_util.h" 13 #include "chrome/browser/permissions/permission_uma_util.h"
14 #include "url/gurl.h" 14 #include "url/gurl.h"
15 15
16 namespace base { 16 namespace base {
17 class Clock; 17 class Clock;
18 } // namespace base 18 } // namespace base
19 19
20 namespace net { 20 namespace net {
21 class ReportSender; 21 class ReportSender;
22 class URLRequestContext; 22 class URLRequestContext;
23 } // namespace net 23 } // namespace net
24 24
25 namespace safe_browsing { 25 namespace safe_browsing {
26 26
27 struct PermissionAndOrigin { 27 struct PermissionAndOrigin {
28 bool operator==(const PermissionAndOrigin& other) const; 28 bool operator==(const PermissionAndOrigin& other) const;
29 29
30 content::PermissionType permission; 30 ContentSettingsType permission;
31 GURL origin; 31 GURL origin;
32 }; 32 };
33 33
34 struct PermissionAndOriginHash { 34 struct PermissionAndOriginHash {
35 std::size_t operator()( 35 std::size_t operator()(
36 const PermissionAndOrigin& permission_and_origin) const; 36 const PermissionAndOrigin& permission_and_origin) const;
37 }; 37 };
38 38
39 // Provides functionality for building and serializing reports about permissions 39 // Provides functionality for building and serializing reports about permissions
40 // to a report collection server. 40 // to a report collection server.
(...skipping 23 matching lines...) Expand all
64 std::unique_ptr<base::Clock> clock); 64 std::unique_ptr<base::Clock> clock);
65 65
66 // Builds and serializes a permission report with |report_info| included. 66 // Builds and serializes a permission report with |report_info| included.
67 // The serialized report is written into |output|. Returns true if the 67 // The serialized report is written into |output|. Returns true if the
68 // serialization was successful and false otherwise. 68 // serialization was successful and false otherwise.
69 static bool BuildReport(const PermissionReportInfo& report_info, 69 static bool BuildReport(const PermissionReportInfo& report_info,
70 std::string* output); 70 std::string* output);
71 71
72 // Returns false if the number of reports sent in the last one minute per 72 // Returns false if the number of reports sent in the last one minute per
73 // origin per permission is under a threshold, otherwise true. 73 // origin per permission is under a threshold, otherwise true.
74 bool IsReportThresholdExceeded(content::PermissionType permission, 74 bool IsReportThresholdExceeded(ContentSettingsType permission,
75 const GURL& origin); 75 const GURL& origin);
76 76
77 std::unique_ptr<net::ReportSender> permission_report_sender_; 77 std::unique_ptr<net::ReportSender> permission_report_sender_;
78 78
79 // TODO(stefanocs): This might introduce a memory issue since older entries 79 // TODO(stefanocs): This might introduce a memory issue since older entries
80 // are not removed until a new report with the corresponding key is added. We 80 // are not removed until a new report with the corresponding key is added. We
81 // should address this issue if that becomes a problem in the future. 81 // should address this issue if that becomes a problem in the future.
82 std::unordered_map<PermissionAndOrigin, 82 std::unordered_map<PermissionAndOrigin,
83 std::queue<base::Time>, 83 std::queue<base::Time>,
84 PermissionAndOriginHash> 84 PermissionAndOriginHash>
85 report_logs_; 85 report_logs_;
86 86
87 std::unique_ptr<base::Clock> clock_; 87 std::unique_ptr<base::Clock> clock_;
88 88
89 DISALLOW_COPY_AND_ASSIGN(PermissionReporter); 89 DISALLOW_COPY_AND_ASSIGN(PermissionReporter);
90 }; 90 };
91 91
92 } // namespace safe_browsing 92 } // namespace safe_browsing
93 93
94 #endif // CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_ 94 #endif // CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698