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

Side by Side 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 unified diff | Download patch
OLDNEW
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 "components/cronet/android/cronet_url_request_context_adapter.h" 5 #include "components/cronet/android/cronet_url_request_context_adapter.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/files/scoped_file.h" 11 #include "base/files/scoped_file.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/prefs/pref_filter.h"
13 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #include "components/cronet/url_request_context_config.h" 16 #include "components/cronet/url_request_context_config.h"
16 #include "jni/CronetUrlRequestContext_jni.h" 17 #include "jni/CronetUrlRequestContext_jni.h"
17 #include "net/base/load_flags.h" 18 #include "net/base/load_flags.h"
18 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
19 #include "net/base/network_delegate_impl.h" 20 #include "net/base/network_delegate_impl.h"
20 #include "net/http/http_auth_handler_factory.h" 21 #include "net/http/http_auth_handler_factory.h"
21 #include "net/log/write_to_file_net_log_observer.h" 22 #include "net/log/write_to_file_net_log_observer.h"
22 #include "net/proxy/proxy_service.h" 23 #include "net/proxy/proxy_service.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 jcronet_url_request_context) { 149 jcronet_url_request_context) {
149 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); 150 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread());
150 DCHECK(!is_context_initialized_); 151 DCHECK(!is_context_initialized_);
151 DCHECK(proxy_config_service_); 152 DCHECK(proxy_config_service_);
152 // TODO(mmenke): Add method to have the builder enable SPDY. 153 // TODO(mmenke): Add method to have the builder enable SPDY.
153 net::URLRequestContextBuilder context_builder; 154 net::URLRequestContextBuilder context_builder;
154 context_builder.set_network_delegate(new BasicNetworkDelegate()); 155 context_builder.set_network_delegate(new BasicNetworkDelegate());
155 context_builder.set_proxy_config_service(proxy_config_service_.release()); 156 context_builder.set_proxy_config_service(proxy_config_service_.release());
156 config->ConfigureURLRequestContextBuilder(&context_builder); 157 config->ConfigureURLRequestContextBuilder(&context_builder);
157 158
159 // Set up pref file if storage path is specified.
160 if (!config->storage_path.empty()) {
161 base::FilePath filepath(config->storage_path);
162 filepath = filepath.Append(FILE_PATH_LITERAL("local_prefs.json"));
163 if (!file_thread_) {
164 file_thread_.reset(new base::Thread("Network File Thread"));
165 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.
166 base::Thread::Options(base::MessageLoop::TYPE_DEFAULT, 0));
167 }
168 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.
169 filepath, file_thread_->task_runner(), scoped_ptr<PrefFilter>());
170 network_json_store_->ReadPrefsAsync(nullptr);
171 context_builder.SetFileTaskRunner(file_thread_->task_runner());
172 }
173
158 context_.reset(context_builder.Build()); 174 context_.reset(context_builder.Build());
159 175
160 default_load_flags_ = net::LOAD_DO_NOT_SAVE_COOKIES | 176 default_load_flags_ = net::LOAD_DO_NOT_SAVE_COOKIES |
161 net::LOAD_DO_NOT_SEND_COOKIES; 177 net::LOAD_DO_NOT_SEND_COOKIES;
162 if (config->load_disable_cache) 178 if (config->load_disable_cache)
163 default_load_flags_ |= net::LOAD_DISABLE_CACHE; 179 default_load_flags_ |= net::LOAD_DISABLE_CACHE;
164 180
165 if (config->enable_sdch) { 181 if (config->enable_sdch) {
166 DCHECK(context_->sdch_manager()); 182 DCHECK(context_->sdch_manager());
167 sdch_owner_.reset( 183 sdch_owner_.reset(
168 new net::SdchOwner(context_->sdch_manager(), context_.get())); 184 new net::SdchOwner(context_->sdch_manager(), context_.get()));
185 if (network_json_store_)
186 sdch_owner_->EnablePersistentStorage(network_json_store_.get());
169 } 187 }
170 188
171 // Currently (circa M39) enabling QUIC requires setting probability threshold. 189 // Currently (circa M39) enabling QUIC requires setting probability threshold.
172 if (config->enable_quic) { 190 if (config->enable_quic) {
173 context_->http_server_properties() 191 context_->http_server_properties()
174 ->SetAlternativeServiceProbabilityThreshold(0.0f); 192 ->SetAlternativeServiceProbabilityThreshold(0.0f);
175 for (auto hint = config->quic_hints.begin(); 193 for (auto hint = config->quic_hints.begin();
176 hint != config->quic_hints.end(); ++hint) { 194 hint != config->quic_hints.end(); ++hint) {
177 const URLRequestContextConfig::QuicHint& quic_hint = **hint; 195 const URLRequestContextConfig::QuicHint& quic_hint = **hint;
178 if (quic_hint.host.empty()) { 196 if (quic_hint.host.empty()) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 } 354 }
337 355
338 static jint SetMinLogLevel(JNIEnv* env, jclass jcaller, jint jlog_level) { 356 static jint SetMinLogLevel(JNIEnv* env, jclass jcaller, jint jlog_level) {
339 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel()); 357 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel());
340 // MinLogLevel is global, shared by all URLRequestContexts. 358 // MinLogLevel is global, shared by all URLRequestContexts.
341 logging::SetMinLogLevel(static_cast<int>(jlog_level)); 359 logging::SetMinLogLevel(static_cast<int>(jlog_level));
342 return old_log_level; 360 return old_log_level;
343 } 361 }
344 362
345 } // namespace cronet 363 } // namespace cronet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698