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

Unified Diff: chrome/browser/safe_browsing/permission_reporter.h

Issue 2089383005: Add throttling to permission reporter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add-hooks-to-permission-layer
Patch Set: Rename constant Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/permission_reporter.h
diff --git a/chrome/browser/safe_browsing/permission_reporter.h b/chrome/browser/safe_browsing/permission_reporter.h
index 523de8e57057aa67d749f31333c690896448f132..83521d5bd640b65d05a7371b1b806cee5f056ebc 100644
--- a/chrome/browser/safe_browsing/permission_reporter.h
+++ b/chrome/browser/safe_browsing/permission_reporter.h
@@ -5,8 +5,11 @@
#ifndef CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_
#define CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_
+#include <queue>
#include <string>
+#include <unordered_map>
+#include "base/time/time.h"
#include "chrome/browser/permissions/permission_uma_util.h"
#include "url/gurl.h"
@@ -17,6 +20,18 @@ class URLRequestContext;
namespace safe_browsing {
+struct PermissionAndOrigin {
+ bool operator==(const PermissionAndOrigin& other) const;
+
+ content::PermissionType permission;
+ GURL origin;
+};
+
+struct PermissionAndOriginHash {
+ std::size_t operator()(
+ const PermissionAndOrigin& permission_and_origin) const;
+};
+
// Provides functionality for building and serializing reports about permissions
// to a report collection server.
class PermissionReporter {
@@ -55,8 +70,18 @@ class PermissionReporter {
PermissionAction action,
std::string* output);
+ // Returns true if the number of reports sent in the last one minute per
+ // origin per permission is less than |kMaximumReportPerOriginPerPermission|,
+ // otherwise false.
raymes 2016/06/27 06:26:56 nit: probably don't reference the constant here, s
stefanocs 2016/06/27 07:34:57 Done.
+ bool IsAllowedToSend(content::PermissionType permission, const GURL& origin);
+
std::unique_ptr<net::ReportSender> permission_report_sender_;
+ std::unordered_map<PermissionAndOrigin,
+ std::queue<base::Time>,
raymes 2016/06/27 06:26:56 I think perhaps we can simplify this a little bit.
stefanocs 2016/06/27 07:34:57 I think it would be possible to have more than fiv
+ PermissionAndOriginHash>
+ sent_histories;
+
DISALLOW_COPY_AND_ASSIGN(PermissionReporter);
};

Powered by Google App Engine
This is Rietveld 408576698