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. 4 5 #include "mojo/services/network/network_context.h" 6 7 #include "base/base_paths.h" 8 #include "base/path_service.h" 9 #include "net/proxy/proxy_service.h" 10 #include "net/url_request/url_request_context.h" 11 #include "net/url_request/url_request_context_builder.h" 12 13 namespace mojo { 14 15 NetworkContext::NetworkContext(const base::FilePath& base_path) { 16 net::URLRequestContextBuilder builder; 17 builder.set_accept_language("en-us,en"); 18 // TODO(darin): This is surely the wrong UA string. 19 builder.set_user_agent("Mojo/0.1"); 20 builder.set_proxy_service(net::ProxyService::CreateDirect()); 21 builder.set_transport_security_persister_path(base_path); 22 23 net::URLRequestContextBuilder::HttpCacheParams cache_params; 24 cache_params.path = base_path.Append(FILE_PATH_LITERAL("Cache")); 25 cache_params.type = net::URLRequestContextBuilder::HttpCacheParams::DISK; 26 builder.EnableHttpCache(cache_params); 27 28 builder.set_file_enabled(true); 29 30 url_request_context_.reset(builder.Build()); 31 } 32 33 NetworkContext::~NetworkContext() { 34 // TODO(darin): Be careful about destruction order of member variables? 35 } 36 37 } // namespace mojo 38