Commit c5734254 authored by Randy Smith's avatar Randy Smith Committed by Commit Bot

Moved SSLInfo type mapping traits over to //services/network

Bug: 785420
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: I67ddf477232a12d3a1848b9982695abce3ec397c
Reviewed-on: https://chromium-review.googlesource.com/773635Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Randy Smith <rdsmith@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521966}
parent 9243479d
......@@ -376,7 +376,8 @@ source_set("common") {
"//ppapi/features",
"//sandbox",
"//sandbox:sandbox_features",
"//services/network/public/interfaces:interfaces",
"//services/network/public/cpp",
"//services/network/public/interfaces",
"//services/resource_coordinator/public/cpp:resource_coordinator_cpp",
"//services/service_manager",
"//services/service_manager/embedder",
......
......@@ -40,102 +40,6 @@ void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Log(
l->append("<HttpResponseHeaders>");
}
namespace {
void WriteCert(base::Pickle* m, net::X509Certificate* cert) {
WriteParam(m, !!cert);
if (cert)
cert->Persist(m);
}
bool ReadCert(const base::Pickle* m,
base::PickleIterator* iter,
scoped_refptr<net::X509Certificate>* cert) {
DCHECK(!*cert);
bool has_object;
if (!ReadParam(m, iter, &has_object))
return false;
if (!has_object)
return true;
*cert = net::X509Certificate::CreateFromPickle(iter);
return !!cert->get();
}
} // namespace
void ParamTraits<net::SSLInfo>::Write(base::Pickle* m, const param_type& p) {
WriteParam(m, p.is_valid());
if (!p.is_valid())
return;
WriteCert(m, p.cert.get());
WriteCert(m, p.unverified_cert.get());
WriteParam(m, p.cert_status);
WriteParam(m, p.security_bits);
WriteParam(m, p.key_exchange_group);
WriteParam(m, p.connection_status);
WriteParam(m, p.is_issued_by_known_root);
WriteParam(m, p.pkp_bypassed);
WriteParam(m, p.client_cert_sent);
WriteParam(m, p.channel_id_sent);
WriteParam(m, p.token_binding_negotiated);
WriteParam(m, p.token_binding_key_param);
WriteParam(m, p.handshake_type);
WriteParam(m, p.public_key_hashes);
WriteParam(m, p.pinning_failure_log);
WriteParam(m, p.signed_certificate_timestamps);
WriteParam(m, p.ct_policy_compliance);
WriteParam(m, p.ocsp_result.response_status);
WriteParam(m, p.ocsp_result.revocation_status);
}
bool ParamTraits<net::SSLInfo>::Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* r) {
bool is_valid = false;
if (!ReadParam(m, iter, &is_valid))
return false;
if (!is_valid)
return true;
return ReadCert(m, iter, &r->cert) &&
ReadCert(m, iter, &r->unverified_cert) &&
ReadParam(m, iter, &r->cert_status) &&
ReadParam(m, iter, &r->security_bits) &&
ReadParam(m, iter, &r->key_exchange_group) &&
ReadParam(m, iter, &r->connection_status) &&
ReadParam(m, iter, &r->is_issued_by_known_root) &&
ReadParam(m, iter, &r->pkp_bypassed) &&
ReadParam(m, iter, &r->client_cert_sent) &&
ReadParam(m, iter, &r->channel_id_sent) &&
ReadParam(m, iter, &r->token_binding_negotiated) &&
ReadParam(m, iter, &r->token_binding_key_param) &&
ReadParam(m, iter, &r->handshake_type) &&
ReadParam(m, iter, &r->public_key_hashes) &&
ReadParam(m, iter, &r->pinning_failure_log) &&
ReadParam(m, iter, &r->signed_certificate_timestamps) &&
ReadParam(m, iter, &r->ct_policy_compliance) &&
ReadParam(m, iter, &r->ocsp_result.response_status) &&
ReadParam(m, iter, &r->ocsp_result.revocation_status);
}
void ParamTraits<net::SSLInfo>::Log(const param_type& p, std::string* l) {
l->append("<SSLInfo>");
}
void ParamTraits<net::HashValue>::Write(base::Pickle* m, const param_type& p) {
WriteParam(m, p.ToString());
}
bool ParamTraits<net::HashValue>::Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* r) {
std::string str;
return ReadParam(m, iter, &str) && r->FromString(str);
}
void ParamTraits<net::HashValue>::Log(const param_type& p, std::string* l) {
l->append("<HashValue>");
}
void ParamTraits<storage::DataElement>::Write(base::Pickle* m,
const param_type& p) {
WriteParam(m, static_cast<int>(p.type()));
......@@ -490,30 +394,4 @@ void ParamTraits<scoped_refptr<content::ResourceRequestBody>>::Log(
l->append("<ResourceRequestBody>");
}
void ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>>::Write(
base::Pickle* m,
const param_type& p) {
WriteParam(m, p.get() != nullptr);
if (p.get())
p->Persist(m);
}
bool ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>>::Read(
const base::Pickle* m,
base::PickleIterator* iter,
param_type* r) {
bool has_object;
if (!ReadParam(m, iter, &has_object))
return false;
if (has_object)
*r = net::ct::SignedCertificateTimestamp::CreateFromPickle(iter);
return true;
}
void ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>>::Log(
const param_type& p,
std::string* l) {
l->append("<SignedCertificateTimestamp>");
}
} // namespace IPC
......@@ -22,14 +22,11 @@
#include "content/public/common/service_worker_modes.h"
#include "ipc/ipc_message_macros.h"
#include "net/base/request_priority.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/http/http_response_info.h"
#include "net/ssl/ssl_info.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "net/url_request/redirect_info.h"
#include "services/network/public/cpp/cors_error_status.h"
#include "services/network/public/cpp/ssl_info_ipc_traits.h"
#include "services/network/public/cpp/url_loader_completion_status.h"
#include "services/network/public/interfaces/fetch_api.mojom.h"
#include "third_party/WebKit/public/platform/WebMixedContentContextType.h"
......@@ -57,26 +54,6 @@ struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > {
static void Log(const param_type& p, std::string* l);
};
template <>
struct CONTENT_EXPORT ParamTraits<net::SSLInfo> {
typedef net::SSLInfo param_type;
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* r);
static void Log(const param_type& p, std::string* l);
};
template <>
struct CONTENT_EXPORT ParamTraits<net::HashValue> {
typedef net::HashValue param_type;
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* r);
static void Log(const param_type& p, std::string* l);
};
template <>
struct CONTENT_EXPORT ParamTraits<storage::DataElement> {
typedef storage::DataElement param_type;
......@@ -117,16 +94,6 @@ struct ParamTraits<scoped_refptr<content::ResourceRequestBody>> {
static void Log(const param_type& p, std::string* l);
};
template <>
struct ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>> {
typedef scoped_refptr<net::ct::SignedCertificateTimestamp> param_type;
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* r);
static void Log(const param_type& p, std::string* l);
};
} // namespace IPC
#endif // INTERNAL_CONTENT_COMMON_RESOURCE_MESSAGES_H_
......@@ -139,17 +106,6 @@ IPC_ENUM_TRAITS_MAX_VALUE( \
net::HttpResponseInfo::ConnectionInfo, \
net::HttpResponseInfo::NUM_OF_CONNECTION_INFOS - 1)
IPC_ENUM_TRAITS_MAX_VALUE(net::TokenBindingParam, net::TB_PARAM_ECDSAP256)
IPC_ENUM_TRAITS_MAX_VALUE(net::SSLInfo::HandshakeType,
net::SSLInfo::HANDSHAKE_FULL)
IPC_ENUM_TRAITS_MAX_VALUE(
net::ct::CTPolicyCompliance,
net::ct::CTPolicyCompliance::CT_POLICY_COMPLIANCE_DETAILS_NOT_AVAILABLE)
IPC_ENUM_TRAITS_MAX_VALUE(net::OCSPVerifyResult::ResponseStatus,
net::OCSPVerifyResult::PARSE_RESPONSE_DATA_ERROR)
IPC_ENUM_TRAITS_MAX_VALUE(net::OCSPRevocationStatus,
net::OCSPRevocationStatus::UNKNOWN)
IPC_ENUM_TRAITS_MAX_VALUE(network::mojom::FetchRequestMode,
network::mojom::FetchRequestMode::kLast)
......@@ -237,13 +193,6 @@ IPC_STRUCT_TRAITS_BEGIN(net::MutableNetworkTrafficAnnotationTag)
IPC_STRUCT_TRAITS_MEMBER(unique_id_hash_code)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(net::SignedCertificateTimestampAndStatus)
IPC_STRUCT_TRAITS_MEMBER(sct)
IPC_STRUCT_TRAITS_MEMBER(status)
IPC_STRUCT_TRAITS_END()
IPC_ENUM_TRAITS_MAX_VALUE(net::ct::SCTVerifyStatus, net::ct::SCT_STATUS_MAX)
IPC_STRUCT_TRAITS_BEGIN(content::ResourceRequest)
IPC_STRUCT_TRAITS_MEMBER(method)
IPC_STRUCT_TRAITS_MEMBER(url)
......
......@@ -4,9 +4,10 @@
mojom = "//content/public/common/url_loader.mojom"
public_headers = [ "//net/ssl/ssl_info.h" ]
traits_headers = [ "//content/common/resource_messages.h" ]
traits_headers = [ "//services/network/public/cpp/ssl_info_ipc_traits.h" ]
deps = [
"//content:export",
"//net:net",
"//net",
"//services/network/public/cpp",
]
type_mappings = [ "content.mojom.SSLInfo=net::SSLInfo" ]
......@@ -8,7 +8,7 @@ public_headers =
traits_headers = [ "//content/common/resource_messages.h" ]
deps = [
"//content:export",
"//net:net",
"//net",
"//services/network/public/cpp",
"//third_party/WebKit/public:blink_headers",
]
......
include_rules = [
"+ipc",
"+net",
]
......@@ -12,6 +12,8 @@ static_library("cpp") {
"mutable_partial_network_traffic_annotation_tag_struct_traits.h",
"net_adapters.cc",
"net_adapters.h",
"ssl_info_ipc_traits.cc",
"ssl_info_ipc_traits.h",
"url_loader_completion_status.cc",
"url_loader_completion_status.h",
]
......@@ -22,6 +24,7 @@ static_library("cpp") {
deps = [
"//base",
"//ipc",
"//mojo/common",
"//net",
]
......
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
per-file *_ipc_traits*.*=set noparent
per-file *_ipc_traits*.*=file://ipc/SECURITY_OWNERS
per-file *_struct_traits*.*=set noparent
per-file *_struct_traits*.*=file://ipc/SECURITY_OWNERS
per-file *.typemap=set noparent
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/network/public/cpp/ssl_info_ipc_traits.h"
#include "ipc/ipc_message_utils.h"
namespace IPC {
namespace {
void WriteCert(base::Pickle* m, net::X509Certificate* cert) {
WriteParam(m, !!cert);
if (cert)
cert->Persist(m);
}
bool ReadCert(const base::Pickle* m,
base::PickleIterator* iter,
scoped_refptr<net::X509Certificate>* cert) {
DCHECK(!*cert);
bool has_object;
if (!ReadParam(m, iter, &has_object))
return false;
if (!has_object)
return true;
*cert = net::X509Certificate::CreateFromPickle(iter);
return !!cert->get();
}
} // namespace
void ParamTraits<net::HashValue>::Write(base::Pickle* m, const param_type& p) {
WriteParam(m, p.ToString());
}
bool ParamTraits<net::HashValue>::Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* r) {
std::string str;
return ReadParam(m, iter, &str) && r->FromString(str);
}
void ParamTraits<net::HashValue>::Log(const param_type& p, std::string* l) {
l->append("<HashValue>");
}
void ParamTraits<net::SSLInfo>::Write(base::Pickle* m, const param_type& p) {
WriteParam(m, p.is_valid());
if (!p.is_valid())
return;
WriteCert(m, p.cert.get());
WriteCert(m, p.unverified_cert.get());
WriteParam(m, p.cert_status);
WriteParam(m, p.security_bits);
WriteParam(m, p.key_exchange_group);
WriteParam(m, p.connection_status);
WriteParam(m, p.is_issued_by_known_root);
WriteParam(m, p.pkp_bypassed);
WriteParam(m, p.client_cert_sent);
WriteParam(m, p.channel_id_sent);
WriteParam(m, p.token_binding_negotiated);
WriteParam(m, p.token_binding_key_param);
WriteParam(m, p.handshake_type);
WriteParam(m, p.public_key_hashes);
WriteParam(m, p.pinning_failure_log);
WriteParam(m, p.signed_certificate_timestamps);
WriteParam(m, p.ct_policy_compliance);
WriteParam(m, p.ocsp_result.response_status);
WriteParam(m, p.ocsp_result.revocation_status);
}
bool ParamTraits<net::SSLInfo>::Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* r) {
bool is_valid = false;
if (!ReadParam(m, iter, &is_valid))
return false;
if (!is_valid)
return true;
return ReadCert(m, iter, &r->cert) &&
ReadCert(m, iter, &r->unverified_cert) &&
ReadParam(m, iter, &r->cert_status) &&
ReadParam(m, iter, &r->security_bits) &&
ReadParam(m, iter, &r->key_exchange_group) &&
ReadParam(m, iter, &r->connection_status) &&
ReadParam(m, iter, &r->is_issued_by_known_root) &&
ReadParam(m, iter, &r->pkp_bypassed) &&
ReadParam(m, iter, &r->client_cert_sent) &&
ReadParam(m, iter, &r->channel_id_sent) &&
ReadParam(m, iter, &r->token_binding_negotiated) &&
ReadParam(m, iter, &r->token_binding_key_param) &&
ReadParam(m, iter, &r->handshake_type) &&
ReadParam(m, iter, &r->public_key_hashes) &&
ReadParam(m, iter, &r->pinning_failure_log) &&
ReadParam(m, iter, &r->signed_certificate_timestamps) &&
ReadParam(m, iter, &r->ct_policy_compliance) &&
ReadParam(m, iter, &r->ocsp_result.response_status) &&
ReadParam(m, iter, &r->ocsp_result.revocation_status);
}
void ParamTraits<net::SSLInfo>::Log(const param_type& p, std::string* l) {
l->append("<SSLInfo>");
}
void ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>>::Write(
base::Pickle* m,
const param_type& p) {
WriteParam(m, p.get() != nullptr);
if (p.get())
p->Persist(m);
}
bool ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>>::Read(
const base::Pickle* m,
base::PickleIterator* iter,
param_type* r) {
bool has_object;
if (!ReadParam(m, iter, &has_object))
return false;
if (has_object)
*r = net::ct::SignedCertificateTimestamp::CreateFromPickle(iter);
return true;
}
void ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>>::Log(
const param_type& p,
std::string* l) {
l->append("<SignedCertificateTimestamp>");
}
} // namespace IPC
// Generation of IPC definitions.
// Generate constructors.
#undef SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_
#include "ipc/struct_constructor_macros.h"
#include "ssl_info_ipc_traits.h"
// Generate destructors.
#undef SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_
#include "ipc/struct_destructor_macros.h"
#include "ssl_info_ipc_traits.h"
// Generate param traits write methods.
#undef SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_
#include "ipc/param_traits_write_macros.h"
namespace IPC {
#include "ssl_info_ipc_traits.h"
} // namespace IPC
// Generate param traits read methods.
#undef SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_
#include "ipc/param_traits_read_macros.h"
namespace IPC {
#include "ssl_info_ipc_traits.h"
} // namespace IPC
// Generate param traits log methods.
#undef SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_
#include "ipc/param_traits_log_macros.h"
namespace IPC {
#include "ssl_info_ipc_traits.h"
} // namespace IPC
// Copyright 2017 The Chromium Authors. All rights reserved.
// 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_SSL_INFO_IPC_TRAITS_H_
#define SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_
#include <string>
#include "base/pickle.h"
#include "ipc/ipc_param_traits.h"
#include "ipc/param_traits_macros.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/ssl/ssl_info.h"
#ifndef INTERNAL_SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_
#define INTERNAL_SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_
// services/network/public/cpp is currently packaged as a static library,
// so there's no need for export defines; it's linked directly into whatever
// other components need it.
// This redefinition is present for the IPC macros below.
#undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT
namespace IPC {
template <>
struct ParamTraits<net::HashValue> {
typedef net::HashValue param_type;
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* r);
static void Log(const param_type& p, std::string* l);
};
template <>
struct ParamTraits<net::SSLInfo> {
typedef net::SSLInfo param_type;
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* r);
static void Log(const param_type& p, std::string* l);
};
template <>
struct ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>> {
typedef scoped_refptr<net::ct::SignedCertificateTimestamp> param_type;
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* r);
static void Log(const param_type& p, std::string* l);
};
} // namespace IPC
#endif // INTERNAL_SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_
IPC_ENUM_TRAITS_MAX_VALUE(
net::ct::CTPolicyCompliance,
net::ct::CTPolicyCompliance::CT_POLICY_COMPLIANCE_DETAILS_NOT_AVAILABLE)
IPC_ENUM_TRAITS_MAX_VALUE(net::OCSPVerifyResult::ResponseStatus,
net::OCSPVerifyResult::PARSE_RESPONSE_DATA_ERROR)
IPC_ENUM_TRAITS_MAX_VALUE(net::OCSPRevocationStatus,
net::OCSPRevocationStatus::UNKNOWN)
IPC_ENUM_TRAITS_MAX_VALUE(net::ct::SCTVerifyStatus, net::ct::SCT_STATUS_MAX)
IPC_ENUM_TRAITS_MAX_VALUE(net::SSLInfo::HandshakeType,
net::SSLInfo::HANDSHAKE_FULL)
IPC_ENUM_TRAITS_MAX_VALUE(net::TokenBindingParam, net::TB_PARAM_ECDSAP256)
IPC_STRUCT_TRAITS_BEGIN(net::SignedCertificateTimestampAndStatus)
IPC_STRUCT_TRAITS_MEMBER(sct)
IPC_STRUCT_TRAITS_MEMBER(status)
IPC_STRUCT_TRAITS_END()
#endif // SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment