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

Unified Diff: net/url_request/url_request_context_builder_v8.h

Issue 2881613002: Allow use of Mojo/V8 ProxyResolvers with URLRequestContextBuilder. (Closed)
Patch Set: Missed some ENABLE_MOJOs Created 3 years, 7 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
« no previous file with comments | « net/url_request/url_request_context_builder.cc ('k') | net/url_request/url_request_context_builder_v8.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_context_builder_v8.h
diff --git a/net/url_request/url_request_context_builder_v8.h b/net/url_request/url_request_context_builder_v8.h
new file mode 100644
index 0000000000000000000000000000000000000000..e44c3598a789755c3e053b02f245de2e590cf86f
--- /dev/null
+++ b/net/url_request/url_request_context_builder_v8.h
@@ -0,0 +1,92 @@
+// Copyright 2017 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.
+
+#ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_V8_H_
+#define NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_V8_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "net/proxy/dhcp_proxy_script_fetcher_factory.h"
+#include "net/proxy/proxy_service.h"
+#include "net/url_request/url_request_context_builder.h"
+
+namespace net {
+
+class HostResolver;
+class NetLog;
+class NetworkDelegate;
+class MojoProxyResolverFactory;
+class URLRequestContext;
+
+// Specialization of URLRequestContextBuilder that can create a ProxyService
+// that uses a V8 ProxyResolver. PAC scripts are run by V8 in process, by
+// default, but a Mojo factory can be passed in for out-of-process resolution.
+// PAC scripts will be fetched using the request context itself. If a
+// PoxyService is set directly via the URLRequestContextBuilder API, it will be
+// used instead of the one this class normally creates.
+class URLRequestContextBuilderV8 : public URLRequestContextBuilder {
+ public:
+ URLRequestContextBuilderV8();
+ ~URLRequestContextBuilderV8() override;
+
+ // If set to false, the URLrequestContextBuilder will create a ProxyService,
+ // which won't use V8. Defaults to true.
+ void set_use_v8(bool use_v8) { use_v8_ = use_v8; }
+
+ // Sets whether quick PAC checks are enabled. Defaults to true. Ignored if
+ // use_v8 is false.
+ void set_quick_check_enabled(bool quick_check_enabled) {
+ quick_check_enabled_ = quick_check_enabled;
+ }
+
+ // Sets policy for sanitizing URLs before passing them a PAC. Defaults to
+ // ProxyService::SanitizeUrlPolicy::SAFE. Ignored if use_v8 is false.
+ void set_pac_sanitize_url_policy(
+ net::ProxyService::SanitizeUrlPolicy sanitize_url_policy) {
+ sanitize_url_policy_ = sanitize_url_policy;
+ }
+
+ // Overrides default DhcpProxyScriptFetcherFactory. Ignored if use_v8 is
+ // false.
+ void set_dhcp_fetcher_factory(
+ std::unique_ptr<DhcpProxyScriptFetcherFactory> dhcp_fetcher_factory) {
+ dhcp_fetcher_factory = std::move(dhcp_fetcher_factory_);
+ }
+
+#ifdef ENABLE_NET_MOJO
+ // Sets Mojo factory used to create ProxyResolvers. If not set, V8 will be
+ // used in process instead of Mojo. Ignored if use_v8 is false. The passed in
+ // factory must outlive the URLRequestContext the builder creates.
+ void set_mojo_proxy_resolver_factory(
+ MojoProxyResolverFactory* mojo_proxy_resolver_factory) {
+ mojo_proxy_resolver_factory_ = mojo_proxy_resolver_factory;
+ }
+#endif // ENABLE_NET_MOJO
+
+ private:
+ std::unique_ptr<ProxyService> CreateProxyService(
+ std::unique_ptr<ProxyConfigService> proxy_config_service,
+ URLRequestContext* url_request_context,
+ HostResolver* host_resolver,
+ NetworkDelegate* network_delegate,
+ NetLog* net_log) override;
+
+ bool use_v8_ = true;
+ bool quick_check_enabled_ = true;
+ net::ProxyService::SanitizeUrlPolicy sanitize_url_policy_ =
+ net::ProxyService::SanitizeUrlPolicy::SAFE;
+
+ std::unique_ptr<DhcpProxyScriptFetcherFactory> dhcp_fetcher_factory_;
+
+#ifdef ENABLE_NET_MOJO
+ MojoProxyResolverFactory* mojo_proxy_resolver_factory_ = nullptr;
+#endif
+
+ DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilderV8);
+};
+
+} // namespace net
+
+#endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_V8_H_
« no previous file with comments | « net/url_request/url_request_context_builder.cc ('k') | net/url_request/url_request_context_builder_v8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698