| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 [DartPackage="mojo_services"] | 5 [DartPackage="mojo_services"] |
| 6 module mojo; | 6 module mojo; |
| 7 | 7 |
| 8 import "mojo/public/interfaces/network/network_error.mojom"; | 8 import "mojo/public/interfaces/network/network_error.mojom"; |
| 9 import "network/interfaces/cookie_store.mojom"; | 9 import "network/interfaces/cookie_store.mojom"; |
| 10 import "network/interfaces/host_resolver.mojom"; | 10 import "network/interfaces/host_resolver.mojom"; |
| 11 import "network/interfaces/http_server.mojom"; | 11 import "network/interfaces/http_server.mojom"; |
| 12 import "network/interfaces/net_address.mojom"; | 12 import "network/interfaces/net_address.mojom"; |
| 13 import "network/interfaces/tcp_bound_socket.mojom"; | 13 import "network/interfaces/tcp_bound_socket.mojom"; |
| 14 import "network/interfaces/tcp_connected_socket.mojom"; | 14 import "network/interfaces/tcp_connected_socket.mojom"; |
| 15 import "network/interfaces/udp_socket.mojom"; | 15 import "network/interfaces/udp_socket.mojom"; |
| 16 import "network/interfaces/url_loader.mojom"; | 16 import "network/interfaces/url_loader.mojom"; |
| 17 import "network/interfaces/url_loader_interceptor.mojom"; | 17 import "network/interfaces/url_loader_interceptor.mojom"; |
| 18 import "network/interfaces/web_socket.mojom"; | 18 import "network/interfaces/web_socket.mojom"; |
| 19 | 19 |
| 20 // TODO Darin suggests that this should probably be two classes. One for | 20 // TODO Darin suggests that this should probably be two classes. One for |
| 21 // high-level origin-build requests like WebSockets and HTTP, and the other for | 21 // high-level origin-build requests like WebSockets and HTTP, and the other for |
| 22 // non-origin-bound low-level stuff like DNS, UDP, and TCP. | 22 // non-origin-bound low-level stuff like DNS, UDP, and TCP. |
| 23 [ServiceName="mojo::NetworkService"] |
| 23 interface NetworkService { | 24 interface NetworkService { |
| 24 CreateURLLoader(URLLoader& loader); | 25 CreateURLLoader(URLLoader& loader); |
| 25 | 26 |
| 26 GetCookieStore(CookieStore& cookie_store); | 27 GetCookieStore(CookieStore& cookie_store); |
| 27 | 28 |
| 28 CreateWebSocket(WebSocket& socket); | 29 CreateWebSocket(WebSocket& socket); |
| 29 | 30 |
| 30 // Creates a TCP socket bound to a given local address. This bound socket | 31 // Creates a TCP socket bound to a given local address. This bound socket |
| 31 // can be used for creating a client or server socket on that local address. | 32 // can be used for creating a client or server socket on that local address. |
| 32 // | 33 // |
| 33 // If you want to create a client socket to connect to a server and are in | 34 // If you want to create a client socket to connect to a server and are in |
| 34 // the common case where you don't care about the local address it's bound | 35 // the common case where you don't care about the local address it's bound |
| 35 // to, use CreateTCPConnectedSocket. | 36 // to, use CreateTCPConnectedSocket. |
| 36 // | 37 // |
| 37 // The local address can specify 0 for the port to specify that the OS should | 38 // The local address can specify 0 for the port to specify that the OS should |
| 38 // pick an available port for the given address, or it can pass 0 for the | 39 // pick an available port for the given address, or it can pass 0 for the |
| 39 // address and port for the OS to pick both the local address and port. In | 40 // address and port for the OS to pick both the local address and port. In |
| 40 // all success cases, the resulting local address will be passed to the | 41 // all success cases, the resulting local address will be passed to the |
| 41 // callback as bound_to. | 42 // callback as bound_to. |
| 42 CreateTCPBoundSocket(NetAddress? local_address, | 43 CreateTCPBoundSocket(NetAddress? local_address, TCPBoundSocket& bound_socket) |
| 43 TCPBoundSocket& bound_socket) | |
| 44 => (NetworkError result, NetAddress? bound_to); | 44 => (NetworkError result, NetAddress? bound_to); |
| 45 | 45 |
| 46 // Creates a client socket connected to the given remote address. A local | 46 // Creates a client socket connected to the given remote address. A local |
| 47 // address and port will be allocated for the connection and passed to the | 47 // address and port will be allocated for the connection and passed to the |
| 48 // callback on success. | 48 // callback on success. |
| 49 // | 49 // |
| 50 // If you want control over the local address and port, instead use | 50 // If you want control over the local address and port, instead use |
| 51 // CreateTCPBoundSocket. | 51 // CreateTCPBoundSocket. |
| 52 // | 52 // |
| 53 // IMPORTANT: This does not work yet! We need to add a new parameter to | 53 // IMPORTANT: This does not work yet! We need to add a new parameter to |
| 54 // indicate the protocol type (IPv4 or IPv6) actually be able to create the | 54 // indicate the protocol type (IPv4 or IPv6) actually be able to create the |
| 55 // right type of socket. We also need to figure out how the client is supposed | 55 // right type of socket. We also need to figure out how the client is supposed |
| 56 // to decide between IPv4 and IPv6 on a given system. | 56 // to decide between IPv4 and IPv6 on a given system. |
| 57 CreateTCPConnectedSocket(NetAddress remote_address, | 57 CreateTCPConnectedSocket(NetAddress remote_address, |
| 58 handle<data_pipe_consumer> send_stream, | 58 handle<data_pipe_consumer> send_stream, |
| 59 handle<data_pipe_producer> receive_stream, | 59 handle<data_pipe_producer> receive_stream, |
| 60 TCPConnectedSocket& client_socket) | 60 TCPConnectedSocket& client_socket) |
| 61 => (NetworkError result, | 61 => (NetworkError result, NetAddress? local_address); |
| 62 NetAddress? local_address); | |
| 63 | 62 |
| 64 CreateUDPSocket(UDPSocket& socket); | 63 CreateUDPSocket(UDPSocket& socket); |
| 65 | 64 |
| 66 // Starts an HTTP server running on the given local address. The delegate will | 65 // Starts an HTTP server running on the given local address. The delegate will |
| 67 // be notified with incoming connections. | 66 // be notified with incoming connections. |
| 68 // | 67 // |
| 69 // The local address can specify 0 for the port to specify that the OS should | 68 // The local address can specify 0 for the port to specify that the OS should |
| 70 // pick an available port for the given address, or it can pass 0 for the | 69 // pick an available port for the given address, or it can pass 0 for the |
| 71 // address and port for the OS to pick both the local address and port. In | 70 // address and port for the OS to pick both the local address and port. In |
| 72 // all success cases, the resulting local address will be passed to the | 71 // all success cases, the resulting local address will be passed to the |
| 73 // callback as bound_to. | 72 // callback as bound_to. |
| 74 CreateHttpServer(NetAddress local_address, | 73 CreateHttpServer(NetAddress local_address, HttpServerDelegate delegate) |
| 75 HttpServerDelegate delegate) | 74 => (NetworkError result, NetAddress? bound_to); |
| 76 => (NetworkError result, | |
| 77 NetAddress? bound_to); | |
| 78 | 75 |
| 79 // Register a new url loader interceptor that will be used on any new | 76 // Register a new url loader interceptor that will be used on any new |
| 80 // URLLoader created with the current connection to the network service. | 77 // URLLoader created with the current connection to the network service. |
| 81 // Interceptors are chained. The last registered interceptor will received the | 78 // Interceptors are chained. The last registered interceptor will received the |
| 82 // requests first and the responses last. | 79 // requests first and the responses last. |
| 83 RegisterURLLoaderInterceptor(URLLoaderInterceptorFactory factory); | 80 RegisterURLLoaderInterceptor(URLLoaderInterceptorFactory factory); |
| 84 | 81 |
| 85 // Create a HostResolver that can be used to do ip <-> host lookups. | 82 // Create a HostResolver that can be used to do ip <-> host lookups. |
| 86 CreateHostResolver(HostResolver& host_resolver); | 83 CreateHostResolver(HostResolver& host_resolver); |
| 87 }; | 84 }; |
| OLD | NEW |