Commit 1ecb303d authored by Nate Fischer's avatar Nate Fischer Committed by Commit Bot

AW: make contextgetter's http cache in memory

Default code path is unchanged, this only changes behavior when the
network service is enabled.

This changes AwURLRequestContextGetter's HTTP cache to be in-memory when
the network service is enabled, to avoid creating a second HTTP cache
(in addition to the NetworkContext's cache).

R=jam@chromium.org

Bug: 887538
Test: N/A
Change-Id: I13073e68a46d6eedaca6d77cf2f96b3ea84fdecb
Cq-Include-Trybots: master.tryserver.chromium.android:android_mojo
Reviewed-on: https://chromium-review.googlesource.com/c/1319334Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Nate Fischer <ntfschr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605762}
parent 5459bb56
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "base/base_paths_android.h" #include "base/base_paths_android.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/feature_list.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
...@@ -65,6 +66,7 @@ ...@@ -65,6 +66,7 @@
#include "net/url_request/url_request_context_builder.h" #include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_intercepting_job_factory.h" #include "net/url_request/url_request_intercepting_job_factory.h"
#include "net/url_request/url_request_interceptor.h" #include "net/url_request/url_request_interceptor.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/network_switches.h" #include "services/network/public/cpp/network_switches.h"
using base::FilePath; using base::FilePath;
...@@ -306,8 +308,13 @@ void AwURLRequestContextGetter::InitializeURLRequestContext() { ...@@ -306,8 +308,13 @@ void AwURLRequestContextGetter::InitializeURLRequestContext() {
std::move(channel_id_service)); std::move(channel_id_service));
net::URLRequestContextBuilder::HttpCacheParams cache_params; net::URLRequestContextBuilder::HttpCacheParams cache_params;
// Note: we create this as IN_MEMORY when the network service is enabled
// only as a temporary measure, to avoid accessing the same HTTP cache from
// two spots in the code.
cache_params.type = cache_params.type =
net::URLRequestContextBuilder::HttpCacheParams::DISK_SIMPLE; base::FeatureList::IsEnabled(network::features::kNetworkService)
? net::URLRequestContextBuilder::HttpCacheParams::IN_MEMORY
: net::URLRequestContextBuilder::HttpCacheParams::DISK_SIMPLE;
cache_params.max_size = 20 * 1024 * 1024; // 20M cache_params.max_size = 20 * 1024 * 1024; // 20M
cache_params.path = cache_path_; cache_params.path = cache_path_;
builder.EnableHttpCache(cache_params); builder.EnableHttpCache(cache_params);
......
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