Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Unified Diff: components/cronet/android/cronet_url_request_context_adapter.cc

Issue 1133883002: [Cronet] Enable persistence mode for Sdch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@quic_server_remove_loop
Patch Set: Address comments Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/cronet/android/cronet_url_request_context_adapter.cc
diff --git a/components/cronet/android/cronet_url_request_context_adapter.cc b/components/cronet/android/cronet_url_request_context_adapter.cc
index ec52c9a4c1721a4219f836f1ef40024629276dd0..f1b00d147da8141646e0b4027eb0d075a53bd32b 100644
--- a/components/cronet/android/cronet_url_request_context_adapter.cc
+++ b/components/cronet/android/cronet_url_request_context_adapter.cc
@@ -10,6 +10,7 @@
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
#include "base/logging.h"
+#include "base/prefs/pref_filter.h"
#include "base/single_thread_task_runner.h"
#include "base/values.h"
#include "components/cronet/url_request_context_config.h"
@@ -155,6 +156,21 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread(
context_builder.set_proxy_config_service(proxy_config_service_.release());
config->ConfigureURLRequestContextBuilder(&context_builder);
+ // Set up pref file if storage path is specified.
+ if (!config->storage_path.empty()) {
+ base::FilePath filepath(config->storage_path);
+ filepath = filepath.Append(FILE_PATH_LITERAL("local_prefs.json"));
+ if (!file_thread_) {
+ file_thread_.reset(new base::Thread("Network File Thread"));
+ file_thread_->StartWithOptions(
mef 2015/05/13 15:15:22 nit: Thread::Start() seems to do the same thing.
xunjieli 2015/05/13 16:57:44 Done.
+ base::Thread::Options(base::MessageLoop::TYPE_DEFAULT, 0));
+ }
+ network_json_store_ = new JsonPrefStore(
mef 2015/05/13 15:15:22 nit: should it be called |json_pref_store_|?
xunjieli 2015/05/13 16:57:44 Done.
+ filepath, file_thread_->task_runner(), scoped_ptr<PrefFilter>());
+ network_json_store_->ReadPrefsAsync(nullptr);
+ context_builder.SetFileTaskRunner(file_thread_->task_runner());
+ }
+
context_.reset(context_builder.Build());
default_load_flags_ = net::LOAD_DO_NOT_SAVE_COOKIES |
@@ -166,6 +182,8 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread(
DCHECK(context_->sdch_manager());
sdch_owner_.reset(
new net::SdchOwner(context_->sdch_manager(), context_.get()));
+ if (network_json_store_)
+ sdch_owner_->EnablePersistentStorage(network_json_store_.get());
}
// Currently (circa M39) enabling QUIC requires setting probability threshold.

Powered by Google App Engine
This is Rietveld 408576698