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

Unified Diff: net/proxy/mojo_proxy_resolver_factory_impl.cc

Issue 918933002: Implement utility-side proxy resolver factory Mojo service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@host-resolver-mojo
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: net/proxy/mojo_proxy_resolver_factory_impl.cc
diff --git a/net/proxy/mojo_proxy_resolver_factory_impl.cc b/net/proxy/mojo_proxy_resolver_factory_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6c4c04a7bac66c05dcaad308095412943d22ee08
--- /dev/null
+++ b/net/proxy/mojo_proxy_resolver_factory_impl.cc
@@ -0,0 +1,82 @@
+// 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/mojo_proxy_resolver_factory_impl.h"
+
+#include "net/dns/host_resolver_mojo.h"
+#include "net/proxy/mojo_proxy_resolver_impl.h"
+#include "net/proxy/proxy_resolver_v8_tracing.h"
+#include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h"
+
+namespace net {
+namespace {
+
+scoped_ptr<ProxyResolver> CreateDefaultProxyResolver(
+ HostResolver* host_resolver) {
+ return make_scoped_ptr(
Anand Mistry (off Chromium) 2015/02/19 05:23:08 ProxyResolverV8::EnsureIsolateCreated();
Sam McNally 2015/02/20 03:25:04 Done.
+ new ProxyResolverV8Tracing(host_resolver, nullptr, nullptr));
+}
+
+// A class to manage the lifetime of a MojoProxyResolverHolder and a
eroman 2015/02/20 01:43:37 Is this comment correct? MojoProxyResolverHolder -
Sam McNally 2015/02/20 03:25:04 Done.
+// HostResolverMojo. An instance will remain while the message pipes for both
+// mojo connections remain open.
+class MojoProxyResolverHolder : public mojo::ErrorHandler {
+ public:
+ MojoProxyResolverHolder(
+ const MojoProxyResolverFactoryImpl::Factory& proxy_resolver_factory,
+ mojo::InterfaceRequest<interfaces::ProxyResolver> request,
+ interfaces::HostResolverPtr host_resolver);
+
+ private:
+ // mojo::ErrorHandler override.
+ void OnConnectionError() override;
+
+ HostResolverMojo host_resolver_;
+ MojoProxyResolverImpl proxy_resolver_;
+ mojo::Binding<interfaces::ProxyResolver> binding_;
+
+ DISALLOW_COPY_AND_ASSIGN(MojoProxyResolverHolder);
+};
+
+MojoProxyResolverHolder::MojoProxyResolverHolder(
+ const MojoProxyResolverFactoryImpl::Factory& proxy_resolver_factory,
+ mojo::InterfaceRequest<interfaces::ProxyResolver> request,
+ interfaces::HostResolverPtr host_resolver)
+ : host_resolver_(host_resolver.Pass(),
+ base::Bind(&MojoProxyResolverHolder::OnConnectionError,
+ base::Unretained(this))),
+ proxy_resolver_(proxy_resolver_factory.Run(&host_resolver_)),
+ binding_(&proxy_resolver_, request.Pass()) {
+ binding_.set_error_handler(this);
eroman 2015/02/20 01:43:37 what is the difference between the error handler o
Sam McNally 2015/02/20 03:25:04 They serve the same function, but operate on oppos
+}
+
+void MojoProxyResolverHolder::OnConnectionError() {
+ delete this;
+}
+
+} // namespace
+
+MojoProxyResolverFactoryImpl::MojoProxyResolverFactoryImpl(
+ const MojoProxyResolverFactoryImpl::Factory& proxy_resolver_factory,
+ mojo::InterfaceRequest<interfaces::ProxyResolverFactory> request)
+ : proxy_resolver_impl_factory_(proxy_resolver_factory),
+ binding_(this, request.Pass()) {
+}
+
+MojoProxyResolverFactoryImpl::MojoProxyResolverFactoryImpl(
+ mojo::InterfaceRequest<interfaces::ProxyResolverFactory> request)
+ : MojoProxyResolverFactoryImpl(base::Bind(&CreateDefaultProxyResolver),
+ request.Pass()) {
+}
+
+MojoProxyResolverFactoryImpl::~MojoProxyResolverFactoryImpl() = default;
+
+void MojoProxyResolverFactoryImpl::CreateResolver(
+ mojo::InterfaceRequest<interfaces::ProxyResolver> request,
+ interfaces::HostResolverPtr host_resolver) {
+ new MojoProxyResolverHolder(proxy_resolver_impl_factory_, request.Pass(),
eroman 2015/02/20 01:43:37 This still doesn't smell right to me. At the very
Sam McNally 2015/02/20 03:25:04 Done.
+ host_resolver.Pass());
+}
+
+} // namespace net
« no previous file with comments | « net/proxy/mojo_proxy_resolver_factory_impl.h ('k') | net/proxy/mojo_proxy_resolver_factory_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698