Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Unified Diff: net/dns/mojo_type_converters.cc

Issue 892393005: Implement browser-side host resolver Mojo service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8-pac-interfaces
Patch Set: Change static_library to source_set. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/dns/mojo_type_converters.h ('k') | net/interfaces/host_resolver_service.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/mojo_type_converters.cc
diff --git a/net/dns/mojo_type_converters.cc b/net/dns/mojo_type_converters.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b9f11e70a4e8089e26df8890d4942e6eec7b15b8
--- /dev/null
+++ b/net/dns/mojo_type_converters.cc
@@ -0,0 +1,51 @@
+// Copyright 2015 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 "net/dns/mojo_type_converters.h"
+
+#include "net/base/address_list.h"
+#include "net/base/net_util.h"
+#include "third_party/mojo/src/mojo/public/cpp/bindings/type_converter.h"
+
+namespace mojo {
+
+// static
+net::HostResolver::RequestInfo
+TypeConverter<net::HostResolver::RequestInfo,
+ net::interfaces::HostResolverRequestInfo>::
+ Convert(const net::interfaces::HostResolverRequestInfo& obj) {
+ net::HostResolver::RequestInfo result(net::HostPortPair(obj.host, obj.port));
+ result.set_address_family(
+ static_cast<net::AddressFamily>(obj.address_family));
+ return result;
+}
+
+// static
+net::interfaces::AddressListPtr
+TypeConverter<net::interfaces::AddressListPtr, net::AddressList>::Convert(
+ const net::AddressList& obj) {
+ net::interfaces::AddressListPtr result(net::interfaces::AddressList::New());
+ for (const auto& endpoint : obj) {
+ net::interfaces::IPEndPointPtr ep(net::interfaces::IPEndPoint::New());
+ ep->port = endpoint.port();
+ ep->address = mojo::Array<uint8_t>::From(endpoint.address());
+ result->addresses.push_back(ep.Pass());
+ }
+ return result.Pass();
+}
+
+// static
+net::AddressList
+TypeConverter<net::AddressList, net::interfaces::AddressList>::Convert(
+ const net::interfaces::AddressList& obj) {
+ net::AddressList address_list;
+ for (size_t i = 0; i < obj.addresses.size(); i++) {
+ const net::interfaces::IPEndPointPtr& ep = obj.addresses[i];
+ address_list.push_back(
+ net::IPEndPoint(ep->address.To<net::IPAddressNumber>(), ep->port));
+ }
+ return address_list;
+}
+
+} // namespace mojo
« no previous file with comments | « net/dns/mojo_type_converters.h ('k') | net/interfaces/host_resolver_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698