chromium/net/network_error_logging/network_error_logging_service.cc

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/network_error_logging/network_error_logging_service.h"

#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>

#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/json/json_reader.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/not_fatal_until.h"
#include "base/rand_util.h"
#include "base/time/clock.h"
#include "base/time/default_clock.h"
#include "base/time/time.h"
#include "base/values.h"
#include "net/base/features.h"
#include "net/base/ip_address.h"
#include "net/base/net_errors.h"
#include "net/base/network_anonymization_key.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/base/url_util.h"
#include "net/log/net_log.h"
#include "net/reporting/reporting_service.h"
#include "net/reporting/reporting_target_type.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace net {

namespace {

const int kMaxJsonSize =;
const int kMaxJsonDepth =;

const char kReportToKey[] =;
const char kMaxAgeKey[] =;
const char kIncludeSubdomainsKey[] =;
const char kSuccessFractionKey[] =;
const char kFailureFractionKey[] =;

const char kApplicationPhase[] =;
const char kConnectionPhase[] =;
const char kDnsPhase[] =;

const char kDnsAddressChangedType[] =;
const char kHttpErrorType[] =;

const struct {} kErrorTypes[] =;

void GetPhaseAndTypeFromNetError(Error error,
                                 std::string* phase_out,
                                 std::string* type_out) {}

bool IsHttpError(const NetworkErrorLoggingService::RequestDetails& request) {}

void RecordSignedExchangeRequestOutcome(
    NetworkErrorLoggingService::RequestOutcome outcome) {}

class NetworkErrorLoggingServiceImpl : public NetworkErrorLoggingService {};

}  // namespace

NetworkErrorLoggingService::NelPolicyKey::NelPolicyKey() = default;

NetworkErrorLoggingService::NelPolicyKey::NelPolicyKey(
    const NetworkAnonymizationKey& network_anonymization_key,
    const url::Origin& origin)
    :{}

NetworkErrorLoggingService::NelPolicyKey::NelPolicyKey(
    const NelPolicyKey& other) = default;

bool NetworkErrorLoggingService::NelPolicyKey::operator<(
    const NelPolicyKey& other) const {}

bool NetworkErrorLoggingService::NelPolicyKey::operator==(
    const NelPolicyKey& other) const {}

bool NetworkErrorLoggingService::NelPolicyKey::operator!=(
    const NelPolicyKey& other) const {}

NetworkErrorLoggingService::NelPolicyKey::~NelPolicyKey() = default;

NetworkErrorLoggingService::WildcardNelPolicyKey::WildcardNelPolicyKey() =
    default;

NetworkErrorLoggingService::WildcardNelPolicyKey::WildcardNelPolicyKey(
    const NetworkAnonymizationKey& network_anonymization_key,
    const std::string& domain)
    :{}

NetworkErrorLoggingService::WildcardNelPolicyKey::WildcardNelPolicyKey(
    const NelPolicyKey& origin_key)
    :{}

NetworkErrorLoggingService::WildcardNelPolicyKey::WildcardNelPolicyKey(
    const WildcardNelPolicyKey& other) = default;

bool NetworkErrorLoggingService::WildcardNelPolicyKey::operator<(
    const WildcardNelPolicyKey& other) const {}

NetworkErrorLoggingService::WildcardNelPolicyKey::~WildcardNelPolicyKey() =
    default;

NetworkErrorLoggingService::NelPolicy::NelPolicy() = default;

NetworkErrorLoggingService::NelPolicy::NelPolicy(const NelPolicy& other) =
    default;

NetworkErrorLoggingService::NelPolicy::~NelPolicy() = default;

NetworkErrorLoggingService::RequestDetails::RequestDetails() = default;

NetworkErrorLoggingService::RequestDetails::RequestDetails(
    const RequestDetails& other) = default;

NetworkErrorLoggingService::RequestDetails::~RequestDetails() = default;

NetworkErrorLoggingService::SignedExchangeReportDetails::
    SignedExchangeReportDetails() = default;

NetworkErrorLoggingService::SignedExchangeReportDetails::
    SignedExchangeReportDetails(const SignedExchangeReportDetails& other) =
        default;

NetworkErrorLoggingService::SignedExchangeReportDetails::
    ~SignedExchangeReportDetails() = default;

const char NetworkErrorLoggingService::kHeaderName[] =;

const char NetworkErrorLoggingService::kReportType[] =;

const char
    NetworkErrorLoggingService::kSignedExchangeRequestOutcomeHistogram[] =;

// Allow NEL reports on regular requests, plus NEL reports on Reporting uploads
// containing only regular requests, but do not allow NEL reports on Reporting
// uploads containing Reporting uploads.
//
// This prevents origins from building purposefully-broken Reporting endpoints
// that generate new NEL reports to bypass the age limit on Reporting reports.
const int NetworkErrorLoggingService::kMaxNestedReportDepth =;

const char NetworkErrorLoggingService::kReferrerKey[] =;
const char NetworkErrorLoggingService::kSamplingFractionKey[] =;
const char NetworkErrorLoggingService::kServerIpKey[] =;
const char NetworkErrorLoggingService::kProtocolKey[] =;
const char NetworkErrorLoggingService::kMethodKey[] =;
const char NetworkErrorLoggingService::kStatusCodeKey[] =;
const char NetworkErrorLoggingService::kElapsedTimeKey[] =;
const char NetworkErrorLoggingService::kPhaseKey[] =;
const char NetworkErrorLoggingService::kTypeKey[] =;

const char NetworkErrorLoggingService::kSignedExchangePhaseValue[] =;
const char NetworkErrorLoggingService::kSignedExchangeBodyKey[] =;
const char NetworkErrorLoggingService::kOuterUrlKey[] =;
const char NetworkErrorLoggingService::kInnerUrlKey[] =;
const char NetworkErrorLoggingService::kCertUrlKey[] =;

// See also: max number of Reporting endpoints specified in ReportingPolicy.
const size_t NetworkErrorLoggingService::kMaxPolicies =;

// static
std::unique_ptr<NetworkErrorLoggingService> NetworkErrorLoggingService::Create(
    PersistentNelStore* store) {}

NetworkErrorLoggingService::~NetworkErrorLoggingService() = default;

void NetworkErrorLoggingService::SetReportingService(
    ReportingService* reporting_service) {}

void NetworkErrorLoggingService::OnShutdown() {}

void NetworkErrorLoggingService::SetClockForTesting(const base::Clock* clock) {}

base::Value NetworkErrorLoggingService::StatusAsValue() const {}

std::set<NetworkErrorLoggingService::NelPolicyKey>
NetworkErrorLoggingService::GetPolicyKeysForTesting() {}

NetworkErrorLoggingService::PersistentNelStore*
NetworkErrorLoggingService::GetPersistentNelStoreForTesting() {}

ReportingService* NetworkErrorLoggingService::GetReportingServiceForTesting() {}

NetworkErrorLoggingService::NetworkErrorLoggingService()
    :{}

}  // namespace net