xref: /aosp_15_r20/external/cronet/net/network_error_logging/network_error_logging_test_util.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2018 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "net/network_error_logging/network_error_logging_test_util.h"
6 
7 #include "base/containers/contains.h"
8 #include "net/base/ip_address.h"
9 
10 namespace net {
11 
12 TestNetworkErrorLoggingService::TestNetworkErrorLoggingService() = default;
13 TestNetworkErrorLoggingService::~TestNetworkErrorLoggingService() = default;
14 
OnHeader(const NetworkAnonymizationKey & network_anonymization_key,const url::Origin & origin,const IPAddress & received_ip_address,const std::string & value)15 void TestNetworkErrorLoggingService::OnHeader(
16     const NetworkAnonymizationKey& network_anonymization_key,
17     const url::Origin& origin,
18     const IPAddress& received_ip_address,
19     const std::string& value) {
20   VLOG(1) << "Received NEL policy for " << origin;
21   Header header;
22   header.network_anonymization_key = network_anonymization_key;
23   header.origin = origin;
24   header.received_ip_address = received_ip_address;
25   header.value = value;
26   headers_.push_back(header);
27 }
28 
OnRequest(RequestDetails details)29 void TestNetworkErrorLoggingService::OnRequest(RequestDetails details) {
30   VLOG(1) << "Created NEL report (status=" << details.status_code
31           << ", depth=" << details.reporting_upload_depth << ") for "
32           << details.uri;
33   errors_.push_back(std::move(details));
34 }
35 
QueueSignedExchangeReport(SignedExchangeReportDetails details)36 void TestNetworkErrorLoggingService::QueueSignedExchangeReport(
37     SignedExchangeReportDetails details) {}
38 
RemoveBrowsingData(const base::RepeatingCallback<bool (const url::Origin &)> & origin_filter)39 void TestNetworkErrorLoggingService::RemoveBrowsingData(
40     const base::RepeatingCallback<bool(const url::Origin&)>& origin_filter) {}
41 
RemoveAllBrowsingData()42 void TestNetworkErrorLoggingService::RemoveAllBrowsingData() {}
43 
MatchesAddressList(const AddressList & address_list) const44 bool TestNetworkErrorLoggingService::Header::MatchesAddressList(
45     const AddressList& address_list) const {
46   return base::Contains(address_list, received_ip_address,
47                         &IPEndPoint::address);
48 }
49 
50 }  // namespace net
51