summaryrefslogtreecommitdiffstats
path: root/net/proxy/in_process_mojo_proxy_resolver_factory.cc
blob: da5f1138304cf80a97f5e97b69b1e953cc9ccb58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// 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/proxy/in_process_mojo_proxy_resolver_factory.h"

#include "base/memory/singleton.h"
#include "net/proxy/mojo_proxy_resolver_factory_impl.h"

namespace net {

// static
InProcessMojoProxyResolverFactory*
InProcessMojoProxyResolverFactory::GetInstance() {
  return Singleton<InProcessMojoProxyResolverFactory>::get();
}

InProcessMojoProxyResolverFactory::InProcessMojoProxyResolverFactory() {
  // Implementation lifetime is strongly bound to the life of the connection via
  // |factory_|. When |factory_| is destroyed, the Mojo connection is terminated
  // which causes this object to be destroyed.
  new MojoProxyResolverFactoryImpl(mojo::GetProxy(&factory_));
}

InProcessMojoProxyResolverFactory::~InProcessMojoProxyResolverFactory() =
    default;

void InProcessMojoProxyResolverFactory::Create(
    mojo::InterfaceRequest<interfaces::ProxyResolver> req,
    interfaces::HostResolverPtr host_resolver) {
  factory_->CreateResolver(req.Pass(), host_resolver.Pass());
}

}  // namespace net