Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Side by Side Diff: net/proxy/in_process_mojo_proxy_resolver_factory.cc

Issue 2326913003: Privatize StrongBinding lifetime management (Closed)
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 #include "net/proxy/in_process_mojo_proxy_resolver_factory.h" 5 #include "net/proxy/in_process_mojo_proxy_resolver_factory.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "mojo/public/cpp/bindings/strong_binding.h"
10 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" 11 #include "net/proxy/mojo_proxy_resolver_factory_impl.h"
11 12
12 namespace net { 13 namespace net {
13 14
14 // static 15 // static
15 InProcessMojoProxyResolverFactory* 16 InProcessMojoProxyResolverFactory*
16 InProcessMojoProxyResolverFactory::GetInstance() { 17 InProcessMojoProxyResolverFactory::GetInstance() {
17 return base::Singleton<InProcessMojoProxyResolverFactory>::get(); 18 return base::Singleton<InProcessMojoProxyResolverFactory>::get();
18 } 19 }
19 20
20 InProcessMojoProxyResolverFactory::InProcessMojoProxyResolverFactory() { 21 InProcessMojoProxyResolverFactory::InProcessMojoProxyResolverFactory() {
21 // Implementation lifetime is strongly bound to the life of the connection via 22 mojo::MakeStrongBinding(base::MakeUnique<MojoProxyResolverFactoryImpl>(),
22 // |factory_|. When |factory_| is destroyed, the Mojo connection is terminated 23 mojo::GetProxy(&factory_));
23 // which causes this object to be destroyed.
24 new MojoProxyResolverFactoryImpl(mojo::GetProxy(&factory_));
25 } 24 }
26 25
27 InProcessMojoProxyResolverFactory::~InProcessMojoProxyResolverFactory() = 26 InProcessMojoProxyResolverFactory::~InProcessMojoProxyResolverFactory() =
28 default; 27 default;
29 28
30 std::unique_ptr<base::ScopedClosureRunner> 29 std::unique_ptr<base::ScopedClosureRunner>
31 InProcessMojoProxyResolverFactory::CreateResolver( 30 InProcessMojoProxyResolverFactory::CreateResolver(
32 const mojo::String& pac_script, 31 const mojo::String& pac_script,
33 mojo::InterfaceRequest<interfaces::ProxyResolver> req, 32 mojo::InterfaceRequest<interfaces::ProxyResolver> req,
34 interfaces::ProxyResolverFactoryRequestClientPtr client) { 33 interfaces::ProxyResolverFactoryRequestClientPtr client) {
35 factory_->CreateResolver(pac_script, std::move(req), std::move(client)); 34 factory_->CreateResolver(pac_script, std::move(req), std::move(client));
36 return nullptr; 35 return nullptr;
37 } 36 }
38 37
39 } // namespace net 38 } // namespace net
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc ('k') | net/proxy/mojo_proxy_resolver_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698