60
60
#include " net/url_request/static_http_user_agent_settings.h"
61
61
#include " net/url_request/url_request_context.h"
62
62
#include " net/url_request/url_request_context_storage.h"
63
+ #include " net/url_request/url_request_intercepting_job_factory.h"
63
64
#include " net/url_request/url_request_job_factory_impl.h"
64
65
#include " ui/base/l10n/l10n_util.h"
65
66
@@ -132,6 +133,7 @@ ShellURLRequestContextGetter::ShellURLRequestContextGetter(
132
133
MessageLoop* file_loop,
133
134
ProtocolHandlerMap* protocol_handlers,
134
135
ShellBrowserContext* browser_context,
136
+ URLRequestInterceptorScopedVector request_interceptors,
135
137
const std::string& auth_schemes,
136
138
const std::string& auth_server_whitelist,
137
139
const std::string& auth_delegate_whitelist,
@@ -149,6 +151,7 @@ ShellURLRequestContextGetter::ShellURLRequestContextGetter(
149
151
io_loop_(io_loop),
150
152
file_loop_(file_loop),
151
153
browser_context_(browser_context),
154
+ request_interceptors_(request_interceptors.Pass()),
152
155
extension_info_map_(extension_info_map){
153
156
// Must first be created on the UI thread.
154
157
DCHECK (BrowserThread::CurrentlyOn (BrowserThread::UI));
@@ -244,7 +247,7 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() {
244
247
net::HttpCache::DefaultBackend* main_backend =
245
248
new net::HttpCache::DefaultBackend (
246
249
net::DISK_CACHE,
247
- net::CACHE_BACKEND_SIMPLE ,
250
+ net::CACHE_BACKEND_BLOCKFILE ,
248
251
cache_path,
249
252
10 * 1024 * 1024 , // 10M
250
253
BrowserThread::GetMessageLoopProxyForThread (
@@ -292,8 +295,19 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() {
292
295
new net::AppProtocolHandler (root_path_));
293
296
job_factory->SetProtocolHandler (" nw" , new nw::NwProtocolHandler ());
294
297
295
- storage_->set_job_factory (job_factory.release ());
298
+ // Set up interceptors in the reverse order.
299
+ scoped_ptr<net::URLRequestJobFactory> top_job_factory =
300
+ job_factory.Pass ();
301
+ for (URLRequestInterceptorScopedVector::reverse_iterator i =
302
+ request_interceptors_.rbegin ();
303
+ i != request_interceptors_.rend ();
304
+ ++i) {
305
+ top_job_factory.reset (new net::URLRequestInterceptingJobFactory (
306
+ top_job_factory.Pass (), make_scoped_ptr (*i)));
307
+ }
308
+ request_interceptors_.weak_clear ();
296
309
310
+ storage_->set_job_factory (top_job_factory.release ());
297
311
}
298
312
299
313
return url_request_context_.get ();
0 commit comments