network_error_logging_test_util.cc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "net/network_error_logging/network_error_logging_test_util.h"
  5. #include <algorithm>
  6. #include "net/base/ip_address.h"
  7. namespace net {
  8. TestNetworkErrorLoggingService::TestNetworkErrorLoggingService() = default;
  9. TestNetworkErrorLoggingService::~TestNetworkErrorLoggingService() = default;
  10. void TestNetworkErrorLoggingService::OnHeader(
  11. const NetworkIsolationKey& network_isolation_key,
  12. const url::Origin& origin,
  13. const IPAddress& received_ip_address,
  14. const std::string& value) {
  15. VLOG(1) << "Received NEL policy for " << origin;
  16. Header header;
  17. header.network_isolation_key = network_isolation_key;
  18. header.origin = origin;
  19. header.received_ip_address = received_ip_address;
  20. header.value = value;
  21. headers_.push_back(header);
  22. }
  23. void TestNetworkErrorLoggingService::OnRequest(RequestDetails details) {
  24. VLOG(1) << "Created NEL report (status=" << details.status_code
  25. << ", depth=" << details.reporting_upload_depth << ") for "
  26. << details.uri;
  27. errors_.push_back(std::move(details));
  28. }
  29. void TestNetworkErrorLoggingService::QueueSignedExchangeReport(
  30. SignedExchangeReportDetails details) {}
  31. void TestNetworkErrorLoggingService::RemoveBrowsingData(
  32. const base::RepeatingCallback<bool(const url::Origin&)>& origin_filter) {}
  33. void TestNetworkErrorLoggingService::RemoveAllBrowsingData() {}
  34. bool TestNetworkErrorLoggingService::Header::MatchesAddressList(
  35. const AddressList& address_list) const {
  36. return std::any_of(address_list.begin(), address_list.end(),
  37. [this](const IPEndPoint& endpoint) {
  38. return endpoint.address() == received_ip_address;
  39. });
  40. }
  41. } // namespace net