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

Unified Diff: net/url_request/url_request_filter.cc

Issue 11293252: Change Interceptors into URLRequestJobFactory::ProtocolHandlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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_filter.cc
diff --git a/net/url_request/url_request_filter.cc b/net/url_request/url_request_filter.cc
index 01b6069107282999088a9e32ce6d4cfae62557f1..d854dceaf8cc601127e36552183d3d3693bb283b 100644
--- a/net/url_request/url_request_filter.cc
+++ b/net/url_request/url_request_filter.cc
@@ -10,6 +10,18 @@
namespace net {
+namespace {
+
+URLRequestJob* ProtocolHandlerFactory(
+ URLRequestJobFactory::ProtocolHandler* protocol_handler,
+ URLRequest* request,
+ NetworkDelegate* network_delegate,
+ const std::string& scheme) {
+ return protocol_handler->MaybeCreateJob(request, network_delegate);
+}
+
+} // namespace
+
URLRequestFilter* URLRequestFilter::shared_instance_ = NULL;
URLRequestFilter::~URLRequestFilter() {}
@@ -31,7 +43,22 @@ URLRequestFilter* URLRequestFilter::GetInstance() {
void URLRequestFilter::AddHostnameHandler(const std::string& scheme,
const std::string& hostname, URLRequest::ProtocolFactory* factory) {
- hostname_handler_map_[make_pair(scheme, hostname)] = factory;
+ AddHostnameCallback(scheme, hostname, base::Bind(factory));
+}
+
+void URLRequestFilter::AddHostnameProtocolHandler(
+ const std::string& scheme,
+ const std::string& hostname,
+ URLRequestJobFactory::ProtocolHandler* protocol_handler) {
+ AddHostnameCallback(scheme, hostname, base::Bind(ProtocolHandlerFactory,
+ protocol_handler));
+}
+
+void URLRequestFilter::AddHostnameCallback(
+ const std::string& scheme,
+ const std::string& hostname,
+ base::Callback<URLRequest::ProtocolFactory> callback) {
+ hostname_handler_map_[make_pair(scheme, hostname)] = callback;
// Register with the ProtocolFactory.
URLRequest::Deprecated::RegisterProtocolFactory(
@@ -130,7 +157,7 @@ URLRequestJob* URLRequestFilter::FindRequestHandler(
HostnameHandlerMap::iterator i =
hostname_handler_map_.find(make_pair(scheme, hostname));
if (i != hostname_handler_map_.end())
- job = i->second(request, network_delegate, scheme);
+ job = i->second.Run(request, network_delegate, scheme);
if (!job) {
// Not in the hostname map, check the url map.

Powered by Google App Engine
This is Rietveld 408576698