base: Make it possible to replace the MessageLoop's task runner
[chromium-blink-merge.git] / net / proxy / mojo_proxy_resolver_factory_impl.h
blobf447759e14a34b7bafeeaf5629586bc7a8db7cda
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef NET_PROXY_MOJO_PROXY_RESOLVER_FACTORY_IMPL_H_
6 #define NET_PROXY_MOJO_PROXY_RESOLVER_FACTORY_IMPL_H_
8 #include <set>
10 #include "base/callback.h"
11 #include "net/interfaces/proxy_resolver_service.mojom.h"
12 #include "net/proxy/proxy_resolver.h"
13 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
15 namespace net {
16 class HostResolver;
17 class ProxyResolverErrorObserver;
18 class ProxyResolverFactory;
20 class MojoProxyResolverFactoryImpl : public interfaces::ProxyResolverFactory {
21 public:
22 using Factory = base::Callback<scoped_ptr<net::ProxyResolverFactory>(
23 HostResolver*,
24 scoped_ptr<ProxyResolverErrorObserver>)>;
26 explicit MojoProxyResolverFactoryImpl(
27 mojo::InterfaceRequest<interfaces::ProxyResolverFactory> request);
28 MojoProxyResolverFactoryImpl(
29 const Factory& proxy_resolver_factory,
30 mojo::InterfaceRequest<interfaces::ProxyResolverFactory> request);
32 ~MojoProxyResolverFactoryImpl() override;
34 private:
35 class Job;
37 // interfaces::ProxyResolverFactory override.
38 void CreateResolver(
39 const mojo::String& pac_script,
40 mojo::InterfaceRequest<interfaces::ProxyResolver> request,
41 interfaces::HostResolverPtr host_resolver,
42 interfaces::ProxyResolverErrorObserverPtr error_observer,
43 interfaces::ProxyResolverFactoryRequestClientPtr client) override;
45 void RemoveJob(Job* job);
47 const Factory proxy_resolver_impl_factory_;
48 mojo::StrongBinding<interfaces::ProxyResolverFactory> binding_;
50 std::set<Job*> jobs_;
52 DISALLOW_COPY_AND_ASSIGN(MojoProxyResolverFactoryImpl);
55 } // namespace net
57 #endif // NET_PROXY_MOJO_PROXY_RESOLVER_FACTORY_IMPL_H_