summaryrefslogtreecommitdiffstats
path: root/net/proxy/in_process_mojo_proxy_resolver_factory.cc
blob: 5e1574b92dda5d29fce91e000fc9d536c627a944 (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
35
36
37
38
39
// 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 <utility>

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

namespace net {

// static
InProcessMojoProxyResolverFactory*
InProcessMojoProxyResolverFactory::GetInstance() {
  return base::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;

scoped_ptr<base::ScopedClosureRunner>
InProcessMojoProxyResolverFactory::CreateResolver(
    const mojo::String& pac_script,
    mojo::InterfaceRequest<interfaces::ProxyResolver> req,
    interfaces::ProxyResolverFactoryRequestClientPtr client) {
  factory_->CreateResolver(pac_script, std::move(req), std::move(client));
  return nullptr;
}

}  // namespace net