| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 std::size_t PermissionAndOriginHash::operator()( | 137 std::size_t PermissionAndOriginHash::operator()( |
| 138 const PermissionAndOrigin& permission_and_origin) const { | 138 const PermissionAndOrigin& permission_and_origin) const { |
| 139 std::size_t permission_hash = | 139 std::size_t permission_hash = |
| 140 static_cast<std::size_t>(permission_and_origin.permission); | 140 static_cast<std::size_t>(permission_and_origin.permission); |
| 141 std::size_t origin_hash = | 141 std::size_t origin_hash = |
| 142 std::hash<std::string>()(permission_and_origin.origin.spec()); | 142 std::hash<std::string>()(permission_and_origin.origin.spec()); |
| 143 return base::HashInts(permission_hash, origin_hash); | 143 return base::HashInts(permission_hash, origin_hash); |
| 144 } | 144 } |
| 145 | 145 |
| 146 PermissionReporter::PermissionReporter(net::URLRequestContext* request_context) | 146 PermissionReporter::PermissionReporter(net::URLRequestContext* request_context) |
| 147 : PermissionReporter( | 147 : PermissionReporter(base::MakeUnique<net::ReportSender>(request_context), |
| 148 base::MakeUnique<net::ReportSender>( | 148 base::WrapUnique(new base::DefaultClock)) {} |
| 149 request_context, | |
| 150 net::ReportSender::CookiesPreference::DO_NOT_SEND_COOKIES), | |
| 151 base::WrapUnique(new base::DefaultClock)) {} | |
| 152 | 149 |
| 153 PermissionReporter::PermissionReporter( | 150 PermissionReporter::PermissionReporter( |
| 154 std::unique_ptr<net::ReportSender> report_sender, | 151 std::unique_ptr<net::ReportSender> report_sender, |
| 155 std::unique_ptr<base::Clock> clock) | 152 std::unique_ptr<base::Clock> clock) |
| 156 : permission_report_sender_(std::move(report_sender)), | 153 : permission_report_sender_(std::move(report_sender)), |
| 157 clock_(std::move(clock)) {} | 154 clock_(std::move(clock)) {} |
| 158 | 155 |
| 159 PermissionReporter::~PermissionReporter() {} | 156 PermissionReporter::~PermissionReporter() {} |
| 160 | 157 |
| 161 void PermissionReporter::SendReport(const PermissionReportInfo& report_info) { | 158 void PermissionReporter::SendReport(const PermissionReportInfo& report_info) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 } | 214 } |
| 218 if (log.size() < kMaximumReportsPerOriginPerPermissionPerMinute) { | 215 if (log.size() < kMaximumReportsPerOriginPerPermissionPerMinute) { |
| 219 log.push(current_time); | 216 log.push(current_time); |
| 220 return false; | 217 return false; |
| 221 } else { | 218 } else { |
| 222 return true; | 219 return true; |
| 223 } | 220 } |
| 224 } | 221 } |
| 225 | 222 |
| 226 } // namespace safe_browsing | 223 } // namespace safe_browsing |
| OLD | NEW |