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

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: even more rebase 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..82d2cf4d0f3bb982169bba75a244304d6a98c8b9 100644
--- a/net/url_request/url_request_job_factory_impl.cc
+++ b/net/url_request/url_request_job_factory_impl.cc
@@ -4,8 +4,10 @@
#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"
@@ -22,6 +24,25 @@ URLRequestJobFactoryImpl::URLRequestJobFactoryImpl() {}
URLRequestJobFactoryImpl::~URLRequestJobFactoryImpl() {}
+// static
+std::unique_ptr<URLRequestJobFactoryImpl>
+URLRequestJobFactoryImpl::CreateWithDefaultProtocolHandlers() {
+ URLRequestJobFactoryImpl* job_factory = new URLRequestJobFactoryImpl;
+ job_factory->SetProtocolHandler("http",
mmenke 2016/04/21 20:58:01 Maybe use the constants in url/url_constants inste
mgersh 2016/04/22 20:27:15 Done.
+ base::WrapUnique(new HttpProtocolHandler));
+ job_factory->SetProtocolHandler("https",
+ base::WrapUnique(new HttpProtocolHandler));
+
+#if !defined(OS_IOS)
+ job_factory->SetProtocolHandler("ws",
+ base::WrapUnique(new HttpProtocolHandler));
+ job_factory->SetProtocolHandler("wss",
+ base::WrapUnique(new HttpProtocolHandler));
+#endif // !defined(OS_IOS)
+
+ return base::WrapUnique(job_factory);
mmenke 2016/04/21 20:58:01 Better to make job_factory a unique_ptr, and then
mgersh 2016/04/22 20:27:15 Done.
+}
+
bool URLRequestJobFactoryImpl::SetProtocolHandler(
const std::string& scheme,
std::unique_ptr<ProtocolHandler> protocol_handler) {
@@ -76,8 +97,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