1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "mojo/services/network/network_context.h"
7 #include "base/base_paths.h"
8 #include "net/proxy/proxy_service.h"
9 #include "net/url_request/url_request_context.h"
10 #include "net/url_request/url_request_context_builder.h"
14 NetworkContext::NetworkContext(const base::FilePath
& base_path
) {
15 net::URLRequestContextBuilder builder
;
16 builder
.set_accept_language("en-us,en");
17 // TODO(darin): This is surely the wrong UA string.
18 builder
.set_user_agent("Mojo/0.1");
19 builder
.set_proxy_service(net::ProxyService::CreateDirect());
20 builder
.set_transport_security_persister_path(base_path
);
22 net::URLRequestContextBuilder::HttpCacheParams cache_params
;
23 cache_params
.path
= base_path
.Append(FILE_PATH_LITERAL("Cache"));
24 // TODO(esprehn): For now store the cache in memory so we can run many shells
25 // in parallel when running tests, otherwise the network services in each
26 // shell will corrupt the disk cache.
27 cache_params
.type
= net::URLRequestContextBuilder::HttpCacheParams::IN_MEMORY
;
28 builder
.EnableHttpCache(cache_params
);
30 builder
.set_file_enabled(true);
32 url_request_context_
.reset(builder
.Build());
35 NetworkContext::~NetworkContext() {
36 // TODO(darin): Be careful about destruction order of member variables?