Commit d1cc658f authored by abarth's avatar abarth Committed by Commit bot

Mojo's network service should use a disk cache on Android

Launching Mojo apps on Android is slow because we keep the network cache in
memory, which means we lose it every time we launch MojoShell. After this CL,
we use a disk cache on Android. Note: We still use a memory cache on desktop
because we want to be able to run many instances of mojo_shell in parallel on
desktop for testing.

R=jamesr@chromium.org
BUG=452226

Review URL: https://codereview.chromium.org/883073003

Cr-Commit-Position: refs/heads/master@{#313642}
parent 95c6d684
...@@ -36,15 +36,20 @@ scoped_ptr<net::URLRequestContext> NetworkContext::MakeURLRequestContext( ...@@ -36,15 +36,20 @@ scoped_ptr<net::URLRequestContext> NetworkContext::MakeURLRequestContext(
builder.set_transport_security_persister_path(base_path); builder.set_transport_security_persister_path(base_path);
net::URLRequestContextBuilder::HttpCacheParams cache_params; net::URLRequestContextBuilder::HttpCacheParams cache_params;
#if defined(OS_ANDROID)
// On Android, we store the cache on disk becase we can run only a single
// instance of the shell at a time.
cache_params.type = net::URLRequestContextBuilder::HttpCacheParams::DISK;
cache_params.path = base_path.Append(FILE_PATH_LITERAL("Cache")); cache_params.path = base_path.Append(FILE_PATH_LITERAL("Cache"));
// TODO(esprehn): For now store the cache in memory so we can run many shells #else
// On desktop, we store the cache in memory so we can run many shells
// in parallel when running tests, otherwise the network services in each // in parallel when running tests, otherwise the network services in each
// shell will corrupt the disk cache. // shell will corrupt the disk cache.
cache_params.type = net::URLRequestContextBuilder::HttpCacheParams::IN_MEMORY; cache_params.type = net::URLRequestContextBuilder::HttpCacheParams::IN_MEMORY;
builder.EnableHttpCache(cache_params); #endif
builder.EnableHttpCache(cache_params);
builder.set_file_enabled(true); builder.set_file_enabled(true);
return make_scoped_ptr(builder.Build()); return make_scoped_ptr(builder.Build());
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment