xref: /aosp_15_r20/external/cronet/url/mojom/scheme_host_port_mojom_traits.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2021 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef URL_MOJOM_SCHEME_HOST_PORT_MOJOM_TRAITS_H_
6 #define URL_MOJOM_SCHEME_HOST_PORT_MOJOM_TRAITS_H_
7 
8 #include "base/component_export.h"
9 #include "url/mojom/scheme_host_port.mojom-shared.h"
10 #include "url/scheme_host_port.h"
11 
12 namespace mojo {
13 
14 template <>
COMPONENT_EXPORT(URL_MOJOM_TRAITS)15 struct COMPONENT_EXPORT(URL_MOJOM_TRAITS)
16     StructTraits<url::mojom::SchemeHostPortDataView, url::SchemeHostPort> {
17   static const std::string& scheme(const url::SchemeHostPort& r) {
18     return r.scheme();
19   }
20   static const std::string& host(const url::SchemeHostPort& r) {
21     return r.host();
22   }
23   static uint16_t port(const url::SchemeHostPort& r) { return r.port(); }
24   static bool Read(url::mojom::SchemeHostPortDataView data,
25                    url::SchemeHostPort* out);
26 };
27 
28 }  // namespace mojo
29 
30 #endif  // URL_MOJOM_SCHEME_HOST_PORT_MOJOM_TRAITS_H_
31