| 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/safe_browsing/permission_reporter.h" | 5 #include "chrome/browser/safe_browsing/permission_reporter.h" |
| 6 | 6 |
| 7 #include <functional> | 7 #include <functional> |
| 8 | 8 |
| 9 #include "base/hash.h" | 9 #include "base/hash.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 const PermissionAndOrigin& permission_and_origin) const { | 126 const PermissionAndOrigin& permission_and_origin) const { |
| 127 std::size_t permission_hash = | 127 std::size_t permission_hash = |
| 128 static_cast<std::size_t>(permission_and_origin.permission); | 128 static_cast<std::size_t>(permission_and_origin.permission); |
| 129 std::size_t origin_hash = | 129 std::size_t origin_hash = |
| 130 std::hash<std::string>()(permission_and_origin.origin.spec()); | 130 std::hash<std::string>()(permission_and_origin.origin.spec()); |
| 131 return base::HashInts(permission_hash, origin_hash); | 131 return base::HashInts(permission_hash, origin_hash); |
| 132 } | 132 } |
| 133 | 133 |
| 134 PermissionReporter::PermissionReporter(net::URLRequestContext* request_context) | 134 PermissionReporter::PermissionReporter(net::URLRequestContext* request_context) |
| 135 : PermissionReporter( | 135 : PermissionReporter( |
| 136 base::WrapUnique(new net::ReportSender( | 136 base::MakeUnique<net::ReportSender>( |
| 137 request_context, | 137 request_context, |
| 138 net::ReportSender::CookiesPreference::DO_NOT_SEND_COOKIES)), | 138 net::ReportSender::CookiesPreference::DO_NOT_SEND_COOKIES), |
| 139 base::WrapUnique(new base::DefaultClock)) {} | 139 base::WrapUnique(new base::DefaultClock)) {} |
| 140 | 140 |
| 141 PermissionReporter::PermissionReporter( | 141 PermissionReporter::PermissionReporter( |
| 142 std::unique_ptr<net::ReportSender> report_sender, | 142 std::unique_ptr<net::ReportSender> report_sender, |
| 143 std::unique_ptr<base::Clock> clock) | 143 std::unique_ptr<base::Clock> clock) |
| 144 : permission_report_sender_(std::move(report_sender)), | 144 : permission_report_sender_(std::move(report_sender)), |
| 145 clock_(std::move(clock)) {} | 145 clock_(std::move(clock)) {} |
| 146 | 146 |
| 147 PermissionReporter::~PermissionReporter() {} | 147 PermissionReporter::~PermissionReporter() {} |
| 148 | 148 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 } | 207 } |
| 208 if (log.size() < kMaximumReportsPerOriginPerPermissionPerMinute) { | 208 if (log.size() < kMaximumReportsPerOriginPerPermissionPerMinute) { |
| 209 log.push(current_time); | 209 log.push(current_time); |
| 210 return false; | 210 return false; |
| 211 } else { | 211 } else { |
| 212 return true; | 212 return true; |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 | 215 |
| 216 } // namespace safe_browsing | 216 } // namespace safe_browsing |
| OLD | NEW |