// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Put Mojo definitions into their own namespace to avoid collisions with C++
// definitions.
// TODO(amistry): Resolve the conflict between these two sets of definitions.
module proxy_resolver.mojom;
import "sandbox/policy/mojom/sandbox.mojom";
import "services/network/public/mojom/ip_address.mojom";
import "services/network/public/mojom/network_anonymization_key.mojom";
import "services/network/public/mojom/network_param.mojom";
import "url/mojom/url.mojom";
// Mirror of net::ProxyResolveDnsOperation.
enum HostResolveOperation {
DNS_RESOLVE,
DNS_RESOLVE_EX,
MY_IP_ADDRESS,
MY_IP_ADDRESS_EX,
};
// Interface for waiting for the result of a HostResolver or myIpAddress()
// query. Disconnecting the interface cancels the request.
interface HostResolverRequestClient {
// |error| is a value in net::Error.
ReportResult(int32 error, array<network.mojom.IPAddress> result);
};
struct ProxyInfo {
array<network.mojom.ProxyChain> proxy_chains;
};
interface ProxyResolver {
// Use a ProxyResolverRequestClient instead of returning a result so we can
// cancel in-flight requests by destroying the client.
//
// |network_anonymization_key| is the NetworkAnonymizationKey used by the DNS cache
// to separate requests made in different contexts.
GetProxyForUrl(
url.mojom.Url url,
network.mojom.NetworkAnonymizationKey network_anonymization_key,
pending_remote<ProxyResolverRequestClient> client);
};
interface ProxyResolverRequestClient {
ReportResult(int32 error, ProxyInfo proxy_info);
Alert(string error);
OnError(int32 line_number, string error);
// Does a DNS lookup for |host|, and invokes |client|'s ReportResult() method
// with the result.
//
// |network_anonymization_key| is the NetworkAnonymizationKey used by the DNS cache
// to separate requests made in different contexts. An IP address received
// from a resolution using one NetworkAnonymizationKey must not be used for a
// request made with a different NetworkAnonymizationKey.
ResolveDns(
string host,
HostResolveOperation operation,
network.mojom.NetworkAnonymizationKey network_anonymization_key,
pending_remote<HostResolverRequestClient> client);
};
// Creates a ProxyResolver that uses the provided PAC script. The ProxyResolver
// will remain valid even after the ProxyResolverFactory has been destroyed.
//
// Destroying |client| before its ReportResult method is invoked may cancel
// creation of the ProxyResolverFactory.
// Note: on Android this lives in the browser process.
[ServiceSandbox=sandbox.mojom.Sandbox.kService]
interface ProxyResolverFactory {
CreateResolver(string pac_script,
pending_receiver<ProxyResolver> receiver,
pending_remote<ProxyResolverFactoryRequestClient> client);
};
interface ProxyResolverFactoryRequestClient {
ReportResult(int32 error);
Alert(string error);
OnError(int32 line_number, string error);
ResolveDns(string host,
HostResolveOperation operation,
network.mojom.NetworkAnonymizationKey network_anonymization_key,
pending_remote<HostResolverRequestClient> client);
};