chromium/components/affiliations/core/browser/hash_affiliation_fetcher.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "components/affiliations/core/browser/hash_affiliation_fetcher.h"

#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "components/affiliations/core/browser/affiliation_api.pb.h"
#include "components/affiliations/core/browser/affiliation_utils.h"
#include "components/affiliations/core/browser/lookup_affiliation_response_parser.h"
#include "components/variations/net/variations_http_headers.h"
#include "crypto/sha2.h"
#include "google_apis/google_api_keys.h"
#include "net/base/load_flags.h"
#include "net/base/url_util.h"
#include "net/http/http_status_code.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "url/gurl.h"

namespace affiliations {

namespace {
constexpr int kPrefixLength =;

// Enumeration listing the possible outcomes of fetching affiliation information
// from the Affiliation API. This is used in UMA histograms, so do not change
// existing values, only add new values at the end.
enum class AffiliationFetchResult {};

#if BUILDFLAG(IS_ANDROID)
constexpr bool kRequestGroupingInfo = false;
#else
// Grouping info is required on desktop to properly display passwords in the
// Password Manager UI.
constexpr bool kRequestGroupingInfo =;
#endif

uint64_t ComputeHashPrefix(const FacetURI& uri) {}

void LogFetchResult(AffiliationFetchResult result,
                    base::TimeDelta fetch_time,
                    size_t response_size = 0) {}
affiliation_pb::LookupAffiliationMask CreateLookupMask(
    const AffiliationFetcherInterface::RequestInfo& request_info) {}

}  // namespace

HashAffiliationFetcher::HashAffiliationFetcher(
    scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
    AffiliationFetcherDelegate* delegate)
    :{}

HashAffiliationFetcher::~HashAffiliationFetcher() = default;

AffiliationFetcherDelegate* HashAffiliationFetcher::delegate() const {}

void HashAffiliationFetcher::StartRequest(
    const std::vector<FacetURI>& facet_uris,
    RequestInfo request_info) {}

const std::vector<FacetURI>& HashAffiliationFetcher::GetRequestedFacetURIs()
    const {}

// static
GURL HashAffiliationFetcher::BuildQueryURL() {}

// static
bool HashAffiliationFetcher::IsFetchPossible() {}

void HashAffiliationFetcher::FinalizeRequest(
    const std::string& payload,
    const GURL& query_url,
    net::NetworkTrafficAnnotationTag traffic_annotation) {}

bool HashAffiliationFetcher::ParseResponse(
    const std::string& serialized_response,
    AffiliationFetcherDelegate::Result* result) const {}

void HashAffiliationFetcher::OnSimpleLoaderComplete(
    std::unique_ptr<std::string> response_body) {}

bool operator==(const AffiliationFetcherInterface::RequestInfo& lhs,
                const AffiliationFetcherInterface::RequestInfo& rhs) = default;

}  // namespace affiliations