chromium/components/commerce/core/parcel/parcels_server_proxy.cc

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

#include "components/commerce/core/parcel/parcels_server_proxy.h"

#include <utility>

#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/json/values_util.h"
#include "base/lazy_instance.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "components/commerce/core/commerce_constants.h"
#include "components/commerce/core/commerce_feature_list.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_status_code.h"
#include "net/traffic_annotation/network_traffic_annotation.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 "url/gurl.h"

namespace commerce {

namespace {
// For creating endpoint fetcher.
const int kDefaultTimeoutMs =;
const char kTimeoutParam[] =;
constexpr base::FeatureParam<int> kTimeoutMs{};

// URL to get parcel status.
const char kDefaultServiceBaseUrl[] =;
const char kBaseUrlParam[] =;
constexpr base::FeatureParam<std::string> kServiceBaseUrl{};
const char kGetStatusPath[] =;
const char kUntrackPath[] =;

// lowerCamelCase JSON proto message keys.
const char kTrackingIdKey[] =;
const char kCarrierKey[] =;
const char kParcelIdsKey[] =;
const char kParcelStatusKey[] =;
const char kParcelIdentifierKey[] =;
const char kParcelStateKey[] =;
const char kTrackingUrlKey[] =;
const char kEstimatedDeliveryDateKey[] =;
const char kSourcePageDomainKey[] =;

constexpr net::NetworkTrafficAnnotationTag
    kStartTrackingParcelTrafficAnnotation =;

constexpr net::NetworkTrafficAnnotationTag
    kStopTrackingParcelTrafficAnnotation =;

constexpr net::NetworkTrafficAnnotationTag
    kStopTrackingAllParcelTrafficAnnotation =;

constexpr net::NetworkTrafficAnnotationTag kGetParcelStatusTrafficAnnotation =;

// Serializes a list of ParcelIdentifier .
base::Value::List Serialize(
    const std::vector<ParcelIdentifier>& parcel_identifiers) {}

// Deserializes a ParcelStatus from JSON.
std::optional<ParcelStatus> Deserialize(const base::Value& value) {}

void OnInvalidParcelIdentifierError(
    ParcelsServerProxy::GetParcelStatusCallback callback) {}

}  // namespace

ParcelsServerProxy::ParcelsServerProxy(
    signin::IdentityManager* identity_manager,
    const scoped_refptr<network::SharedURLLoaderFactory>& url_loader_factory)
    :{}

ParcelsServerProxy::~ParcelsServerProxy() = default;

void ParcelsServerProxy::GetParcelStatus(
    const std::vector<ParcelIdentifier>& parcel_identifiers,
    GetParcelStatusCallback callback) {}

void ParcelsServerProxy::StartTrackingParcels(
    const std::vector<ParcelIdentifier>& parcel_identifiers,
    const std::string& source_page_domain,
    GetParcelStatusCallback callback) {}

void ParcelsServerProxy::StopTrackingParcel(
    const std::string& tracking_id,
    StopParcelTrackingCallback callback) {}

void ParcelsServerProxy::StopTrackingParcels(
    const std::vector<ParcelIdentifier>& parcel_identifiers,
    StopParcelTrackingCallback callback) {}

void ParcelsServerProxy::StopTrackingAllParcels(
    StopParcelTrackingCallback callback) {}

std::unique_ptr<EndpointFetcher> ParcelsServerProxy::CreateEndpointFetcher(
    const GURL& url,
    const std::string& http_method,
    const std::string& post_data,
    const net::NetworkTrafficAnnotationTag traffic_annotation) {}

void ParcelsServerProxy::ProcessGetParcelStatusResponse(
    ParcelRequestType request_type,
    GetParcelStatusCallback callback,
    std::unique_ptr<EndpointFetcher> endpoint_fetcher,
    std::unique_ptr<EndpointResponse> response) {}

void ParcelsServerProxy::OnGetParcelStatusJsonParsed(
    ParcelRequestType request_type,
    GetParcelStatusCallback callback,
    data_decoder::DataDecoder::ValueOrError result) {}

void ParcelsServerProxy::OnStopTrackingResponse(
    ParcelRequestType request_type,
    StopParcelTrackingCallback callback,
    std::unique_ptr<EndpointFetcher> endpoint_fetcher,
    std::unique_ptr<EndpointResponse> response) {}

void ParcelsServerProxy::OnServerResponse(
    EndpointCallback callback,
    std::unique_ptr<EndpointFetcher> endpoint_fetcher,
    std::unique_ptr<EndpointResponse> response) {}

void ParcelsServerProxy::SendJsonRequestToServer(
    base::Value::Dict request_json,
    const GURL& server_url,
    const net::NetworkTrafficAnnotationTag& network_traffic_annotation,
    EndpointCallback callback) {}

void ParcelsServerProxy::SendStopTrackingRequestToServer(
    ParcelRequestType request_type,
    const GURL& server_url,
    const net::NetworkTrafficAnnotationTag& network_traffic_annotation,
    StopParcelTrackingCallback callback) {}

}  // namespace commerce