| // Copyright 2018 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. |
| |
| module network.mojom; |
| |
| import "net/interfaces/ip_endpoint.mojom"; |
| import "services/network/public/mojom/mutable_network_traffic_annotation_tag.mojom"; |
| import "url/mojom/url.mojom"; |
| |
| // Represents a connected socket that respects system's proxy settings. Writes |
| // and Reads are through the data pipes supplied upon construction. Consumer |
| // can close the socket by destroying the interface pointer. |
| interface ProxyResolvingSocket{ |
| // Gets the peer address. On success, |net_error| is |
| // net::OK and |peer_addr| contains the peer address. On failure, |
| // |peer_addr| is null and |net_error| is a net error code. If socket is |
| // connected to a proxy, |net_error| will be net::ERR_NAME_NOT_RESOLVED, and |
| // |peer_addr| will be empty. |
| GetPeerAddress() => (int32 net_error, net.interfaces.IPEndPoint? peer_addr); |
| |
| // TODO(xunjieli): Add methods to configure the socket connection and allow |
| // consumers to specify whether they want to disconnect or return the socket |
| // to socket pools. |
| }; |
| |
| // Factory interface for creating ProxyResolvingSocket. Each factory instance |
| // has separate socket pools from the NetworkContext which created the |
| // factory instance. |
| interface ProxyResolvingSocketFactory { |
| // Creates a socket connected to |url|. This connection might be done through |
| // proxies if any is set in system's proxy settings. If |use_tls|, a TLS |
| // connection will be established on top of a TCP connection. On success, |
| // |result| is net::OK. Caller is to use |send_stream| to send data and |
| // |receive_stream| to receive data over the connection. On failure, |result| |
| // is a network error code. |
| // |
| // Any sockets that are created but are yet to be destroyed will be destroyed |
| // when the implementation of this factory goes away. |
| CreateProxyResolvingSocket(url.mojom.Url url, bool use_tls, |
| MutableNetworkTrafficAnnotationTag traffic_annotation, |
| ProxyResolvingSocket& socket) |
| => (int32 result, |
| net.interfaces.IPEndPoint? local_addr, |
| handle<data_pipe_consumer>? receive_stream, |
| handle<data_pipe_producer>? send_stream); |
| }; |