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

Unified Diff: net/url_request/url_request_job_factory_impl.cc

Issue 1888963004: Add HttpProtocolHandler and convert everything to use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove-supports-scheme
Patch Set: more addressing comments Created 4 years, 8 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/url_request/url_request_job_factory_impl.cc
diff --git a/net/url_request/url_request_job_factory_impl.cc b/net/url_request/url_request_job_factory_impl.cc
index af97e620850c1ebc565f7c6387bfe3fc124c6f92..681c94157132de4e495f8c3fcda515b77c561fd2 100644
--- a/net/url_request/url_request_job_factory_impl.cc
+++ b/net/url_request/url_request_job_factory_impl.cc
@@ -4,11 +4,14 @@
#include "net/url_request/url_request_job_factory_impl.h"
+#include "base/memory/ptr_util.h"
#include "base/stl_util.h"
#include "net/base/load_flags.h"
+#include "net/url_request/http_protocol_handler.h"
#include "net/url_request/url_request_interceptor.h"
#include "net/url_request/url_request_job_manager.h"
#include "url/gurl.h"
+#include "url/url_constants.h"
namespace net {
@@ -22,6 +25,26 @@ URLRequestJobFactoryImpl::URLRequestJobFactoryImpl() {}
URLRequestJobFactoryImpl::~URLRequestJobFactoryImpl() {}
+// static
+std::unique_ptr<URLRequestJobFactoryImpl>
+URLRequestJobFactoryImpl::CreateWithHttpProtocolHandlers() {
+ std::unique_ptr<URLRequestJobFactoryImpl> job_factory(
+ new URLRequestJobFactoryImpl);
+ job_factory->SetProtocolHandler(url::kHttpScheme,
+ base::WrapUnique(new HttpProtocolHandler));
+ job_factory->SetProtocolHandler(url::kHttpsScheme,
+ base::WrapUnique(new HttpProtocolHandler));
+
+#if !defined(OS_IOS)
+ job_factory->SetProtocolHandler(url::kWsScheme,
+ base::WrapUnique(new HttpProtocolHandler));
+ job_factory->SetProtocolHandler(url::kWssScheme,
+ base::WrapUnique(new HttpProtocolHandler));
+#endif // !defined(OS_IOS)
+
+ return job_factory;
+}
+
bool URLRequestJobFactoryImpl::SetProtocolHandler(
const std::string& scheme,
std::unique_ptr<ProtocolHandler> protocol_handler) {
@@ -76,8 +99,7 @@ URLRequestJob* URLRequestJobFactoryImpl::MaybeInterceptResponse(
bool URLRequestJobFactoryImpl::IsHandledProtocol(
const std::string& scheme) const {
DCHECK(CalledOnValidThread());
- return ContainsKey(protocol_handler_map_, scheme) ||
- URLRequestJobManager::SupportsScheme(scheme);
+ return ContainsKey(protocol_handler_map_, scheme);
}
bool URLRequestJobFactoryImpl::IsHandledURL(const GURL& url) const {

Powered by Google App Engine
This is Rietveld 408576698