chromium/services/network/public/cpp/net_ipc_param_traits.h

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

#ifndef SERVICES_NETWORK_PUBLIC_CPP_NET_IPC_PARAM_TRAITS_H_
#define SERVICES_NETWORK_PUBLIC_CPP_NET_IPC_PARAM_TRAITS_H_

#include <string>

#include "base/component_export.h"
#include "base/memory/scoped_refptr.h"
#include "base/pickle.h"
#include "ipc/ipc_param_traits.h"
#include "ipc/param_traits_macros.h"
#include "net/base/auth.h"
#include "net/base/host_port_pair.h"
#include "net/base/ip_address.h"
#include "net/base/ip_endpoint.h"
#include "net/base/load_timing_info.h"
#include "net/base/proxy_server.h"
#include "net/base/request_priority.h"
#include "net/base/schemeful_site.h"
#include "net/cert/ct_policy_status.h"
#include "net/cert/signed_certificate_timestamp.h"
#include "net/cert/signed_certificate_timestamp_and_status.h"
#include "net/cert/x509_certificate.h"
#include "net/dns/public/resolve_error_info.h"
#include "net/http/http_connection_info.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
#include "net/nqe/effective_connection_type.h"
#include "net/ssl/ssl_info.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "net/url_request/redirect_info.h"
#include "net/url_request/referrer_policy.h"
#include "url/ipc/url_param_traits.h"
#include "url/origin.h"

// This file defines IPC::ParamTraits for net:: classes / structs.
// For IPC::ParamTraits for network:: class / structs,
// see network_ipc_param_traits.h.

#ifndef INTERNAL_SERVICES_NETWORK_PUBLIC_CPP_NET_IPC_PARAM_TRAITS_H_
#define INTERNAL_SERVICES_NETWORK_PUBLIC_CPP_NET_IPC_PARAM_TRAITS_H_

#undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT

namespace net {
class CertVerifyResult;
}

namespace IPC {

template <>
struct COMPONENT_EXPORT(NETWORK_CPP_NETWORK_PARAM)
    ParamTraits<net::AuthCredentials> {};

template <>
struct COMPONENT_EXPORT(NETWORK_CPP_NETWORK_PARAM)
    ParamTraits<net::CertVerifyResult> {};

template <>
struct COMPONENT_EXPORT(NETWORK_CPP_NETWORK_PARAM) ParamTraits<net::HashValue> {};

template <>
struct COMPONENT_EXPORT(NETWORK_CPP_NETWORK_PARAM)
    ParamTraits<net::IPEndPoint> {};

template <>
struct COMPONENT_EXPORT(NETWORK_CPP_NETWORK_PARAM) ParamTraits<net::IPAddress> {};

template <>
struct COMPONENT_EXPORT(NETWORK_CPP_NETWORK_PARAM)
    ParamTraits<net::HttpRequestHeaders> {};

template <>
struct COMPONENT_EXPORT(NETWORK_CPP_NETWORK_PARAM)
    ParamTraits<bssl::OCSPVerifyResult> {};

template <>
struct COMPONENT_EXPORT(NETWORK_CPP_NETWORK_PARAM)
    ParamTraits<net::ResolveErrorInfo> {};

template <>
struct COMPONENT_EXPORT(NETWORK_CPP_NETWORK_PARAM) ParamTraits<net::SSLInfo> {};

template <>
struct COMPONENT_EXPORT(NETWORK_CPP_NETWORK_PARAM)
    ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>> {};

template <>
struct COMPONENT_EXPORT(NETWORK_CPP_NETWORK_PARAM)
    ParamTraits<scoped_refptr<net::HttpResponseHeaders>> {};

template <>
struct COMPONENT_EXPORT(NETWORK_CPP_NETWORK_PARAM)
    ParamTraits<scoped_refptr<net::X509Certificate>> {};

template <>
struct COMPONENT_EXPORT(NETWORK_CPP_NETWORK_PARAM)
    ParamTraits<net::LoadTimingInfo> {};

template <>
struct COMPONENT_EXPORT(NETWORK_CPP_NETWORK_PARAM)
    ParamTraits<net::SiteForCookies> {};

template <>
struct COMPONENT_EXPORT(NETWORK_CPP_NETWORK_PARAM) ParamTraits<url::Origin> {};

template <>
struct COMPONENT_EXPORT(NETWORK_CPP_NETWORK_PARAM)
    ParamTraits<net::SchemefulSite> {};

}  // namespace IPC

#endif  // INTERNAL_SERVICES_NETWORK_PUBLIC_CPP_NET_IPC_PARAM_TRAITS_H_

IPC_ENUM_TRAITS_MAX_VALUE(
    net::ct::CTPolicyCompliance,
    net::ct::CTPolicyCompliance::CT_POLICY_COMPLIANCE_DETAILS_NOT_AVAILABLE)

IPC_ENUM_TRAITS(net::ProxyServer::Scheme)  // BitMask.

IPC_ENUM_TRAITS_MAX_VALUE(bssl::OCSPVerifyResult::ResponseStatus,
                          bssl::OCSPVerifyResult::PARSE_RESPONSE_DATA_ERROR)
IPC_ENUM_TRAITS_MAX_VALUE(bssl::OCSPRevocationStatus,
                          bssl::OCSPRevocationStatus::UNKNOWN)

IPC_ENUM_TRAITS_MAX_VALUE(net::ct::SCTVerifyStatus, net::ct::SCT_STATUS_MAX)
IPC_ENUM_TRAITS_MAX_VALUE(net::RequestPriority, net::MAXIMUM_PRIORITY)

IPC_ENUM_TRAITS_MAX_VALUE(net::SSLInfo::HandshakeType,
                          net::SSLInfo::HANDSHAKE_FULL)

IPC_ENUM_TRAITS_MAX_VALUE(net::ReferrerPolicy, net::ReferrerPolicy::MAX)

IPC_STRUCT_TRAITS_BEGIN(net::HttpRequestHeaders::HeaderKeyValuePair)
  IPC_STRUCT_TRAITS_MEMBER()
  IPC_STRUCT_TRAITS_MEMBER()
IPC_STRUCT_TRAITS_END()

IPC_STRUCT_TRAITS_BEGIN(net::MutableNetworkTrafficAnnotationTag)
  IPC_STRUCT_TRAITS_MEMBER()
IPC_STRUCT_TRAITS_END()

IPC_STRUCT_TRAITS_BEGIN(net::SignedCertificateTimestampAndStatus)
  IPC_STRUCT_TRAITS_MEMBER()
  IPC_STRUCT_TRAITS_MEMBER()
IPC_STRUCT_TRAITS_END()

IPC_STRUCT_TRAITS_BEGIN(net::RedirectInfo)
  IPC_STRUCT_TRAITS_MEMBER()
  IPC_STRUCT_TRAITS_MEMBER()
  IPC_STRUCT_TRAITS_MEMBER()
  IPC_STRUCT_TRAITS_MEMBER()
  IPC_STRUCT_TRAITS_MEMBER()
  IPC_STRUCT_TRAITS_MEMBER()
  IPC_STRUCT_TRAITS_MEMBER()
  IPC_STRUCT_TRAITS_MEMBER()
  IPC_STRUCT_TRAITS_MEMBER()
IPC_STRUCT_TRAITS_END()

IPC_ENUM_TRAITS_MAX_VALUE(net::HttpConnectionInfo,
                          net::HttpConnectionInfo::kMaxValue)

IPC_ENUM_TRAITS_MAX_VALUE(net::EffectiveConnectionType,
                          net::EFFECTIVE_CONNECTION_TYPE_LAST - 1)

#endif  // SERVICES_NETWORK_PUBLIC_CPP_NET_IPC_PARAM_TRAITS_H_