Update to latest URLRequestJobFactory API

This commit is contained in:
Cheng Zhao 2015-01-09 19:10:31 -08:00
parent 92142ee372
commit 9a5698807f
2 changed files with 23 additions and 3 deletions

View file

@ -50,7 +50,7 @@ ProtocolHandler* AtomURLRequestJobFactory::ReplaceProtocol(
base::AutoLock locked(lock_); base::AutoLock locked(lock_);
if (!ContainsKey(protocol_handler_map_, scheme)) if (!ContainsKey(protocol_handler_map_, scheme))
return NULL; return nullptr;
ProtocolHandler* original_protocol_handler = protocol_handler_map_[scheme]; ProtocolHandler* original_protocol_handler = protocol_handler_map_[scheme];
protocol_handler_map_[scheme] = protocol_handler; protocol_handler_map_[scheme] = protocol_handler;
return original_protocol_handler; return original_protocol_handler;
@ -63,7 +63,7 @@ ProtocolHandler* AtomURLRequestJobFactory::GetProtocolHandler(
base::AutoLock locked(lock_); base::AutoLock locked(lock_);
ProtocolHandlerMap::const_iterator it = protocol_handler_map_.find(scheme); ProtocolHandlerMap::const_iterator it = protocol_handler_map_.find(scheme);
if (it == protocol_handler_map_.end()) if (it == protocol_handler_map_.end())
return NULL; return nullptr;
return it->second; return it->second;
} }
@ -82,10 +82,23 @@ net::URLRequestJob* AtomURLRequestJobFactory::MaybeCreateJobWithProtocolHandler(
base::AutoLock locked(lock_); base::AutoLock locked(lock_);
ProtocolHandlerMap::const_iterator it = protocol_handler_map_.find(scheme); ProtocolHandlerMap::const_iterator it = protocol_handler_map_.find(scheme);
if (it == protocol_handler_map_.end()) if (it == protocol_handler_map_.end())
return NULL; return nullptr;
return it->second->MaybeCreateJob(request, network_delegate); return it->second->MaybeCreateJob(request, network_delegate);
} }
net::URLRequestJob* AtomURLRequestJobFactory::MaybeInterceptRedirect(
net::URLRequest* request,
net::NetworkDelegate* network_delegate,
const GURL& location) const {
return nullptr;
}
net::URLRequestJob* AtomURLRequestJobFactory::MaybeInterceptResponse(
net::URLRequest* request,
net::NetworkDelegate* network_delegate) const {
return nullptr;
}
bool AtomURLRequestJobFactory::IsHandledProtocol( bool AtomURLRequestJobFactory::IsHandledProtocol(
const std::string& scheme) const { const std::string& scheme) const {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());

View file

@ -44,6 +44,13 @@ class AtomURLRequestJobFactory : public net::URLRequestJobFactory {
const std::string& scheme, const std::string& scheme,
net::URLRequest* request, net::URLRequest* request,
net::NetworkDelegate* network_delegate) const override; net::NetworkDelegate* network_delegate) const override;
net::URLRequestJob* MaybeInterceptRedirect(
net::URLRequest* request,
net::NetworkDelegate* network_delegate,
const GURL& location) const override;
net::URLRequestJob* MaybeInterceptResponse(
net::URLRequest* request,
net::NetworkDelegate* network_delegate) const override;
bool IsHandledProtocol(const std::string& scheme) const override; bool IsHandledProtocol(const std::string& scheme) const override;
bool IsHandledURL(const GURL& url) const override; bool IsHandledURL(const GURL& url) const override;
bool IsSafeRedirectTarget(const GURL& location) const override; bool IsSafeRedirectTarget(const GURL& location) const override;