OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/services/network/network_context.h" | 5 #include "mojo/services/network/network_context.h" |
6 | 6 |
7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "net/proxy/proxy_service.h" | 9 #include "net/proxy/proxy_service.h" |
10 #include "net/url_request/url_request_context.h" | 10 #include "net/url_request/url_request_context.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 scoped_ptr<net::URLRequestContext> NetworkContext::MakeURLRequestContext( | 29 scoped_ptr<net::URLRequestContext> NetworkContext::MakeURLRequestContext( |
30 const base::FilePath& base_path) { | 30 const base::FilePath& base_path) { |
31 net::URLRequestContextBuilder builder; | 31 net::URLRequestContextBuilder builder; |
32 builder.set_accept_language("en-us,en"); | 32 builder.set_accept_language("en-us,en"); |
33 // TODO(darin): This is surely the wrong UA string. | 33 // TODO(darin): This is surely the wrong UA string. |
34 builder.set_user_agent("Mojo/0.1"); | 34 builder.set_user_agent("Mojo/0.1"); |
35 builder.set_proxy_service(net::ProxyService::CreateDirect()); | 35 builder.set_proxy_service(net::ProxyService::CreateDirect()); |
36 builder.set_transport_security_persister_path(base_path); | 36 builder.set_transport_security_persister_path(base_path); |
37 | 37 |
38 net::URLRequestContextBuilder::HttpCacheParams cache_params; | 38 net::URLRequestContextBuilder::HttpCacheParams cache_params; |
| 39 #if defined(OS_ANDROID) |
| 40 // On Android, we store the cache on disk becase we can run only a single |
| 41 // instance of the shell at a time. |
| 42 cache_params.type = net::URLRequestContextBuilder::HttpCacheParams::DISK; |
39 cache_params.path = base_path.Append(FILE_PATH_LITERAL("Cache")); | 43 cache_params.path = base_path.Append(FILE_PATH_LITERAL("Cache")); |
40 // TODO(esprehn): For now store the cache in memory so we can run many shells | 44 #else |
| 45 // On desktop, we store the cache in memory so we can run many shells |
41 // in parallel when running tests, otherwise the network services in each | 46 // in parallel when running tests, otherwise the network services in each |
42 // shell will corrupt the disk cache. | 47 // shell will corrupt the disk cache. |
43 cache_params.type = net::URLRequestContextBuilder::HttpCacheParams::IN_MEMORY; | 48 cache_params.type = net::URLRequestContextBuilder::HttpCacheParams::IN_MEMORY; |
| 49 #endif |
| 50 |
44 builder.EnableHttpCache(cache_params); | 51 builder.EnableHttpCache(cache_params); |
45 | |
46 builder.set_file_enabled(true); | 52 builder.set_file_enabled(true); |
47 | |
48 return make_scoped_ptr(builder.Build()); | 53 return make_scoped_ptr(builder.Build()); |
49 } | 54 } |
50 | 55 |
51 } // namespace mojo | 56 } // namespace mojo |
OLD | NEW |