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

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: Missing include 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_->Start();
166 }
167 json_pref_store_ = new JsonPrefStore(
168 filepath, file_thread_->task_runner(), scoped_ptr<PrefFilter>());
169 json_pref_store_->ReadPrefsAsync(nullptr);
170 context_builder.SetFileTaskRunner(file_thread_->task_runner());
171 }
172
158 context_.reset(context_builder.Build()); 173 context_.reset(context_builder.Build());
159 174
160 default_load_flags_ = net::LOAD_DO_NOT_SAVE_COOKIES | 175 default_load_flags_ = net::LOAD_DO_NOT_SAVE_COOKIES |
161 net::LOAD_DO_NOT_SEND_COOKIES; 176 net::LOAD_DO_NOT_SEND_COOKIES;
162 if (config->load_disable_cache) 177 if (config->load_disable_cache)
163 default_load_flags_ |= net::LOAD_DISABLE_CACHE; 178 default_load_flags_ |= net::LOAD_DISABLE_CACHE;
164 179
165 if (config->enable_sdch) { 180 if (config->enable_sdch) {
166 DCHECK(context_->sdch_manager()); 181 DCHECK(context_->sdch_manager());
167 sdch_owner_.reset( 182 sdch_owner_.reset(
168 new net::SdchOwner(context_->sdch_manager(), context_.get())); 183 new net::SdchOwner(context_->sdch_manager(), context_.get()));
184 if (json_pref_store_)
185 sdch_owner_->EnablePersistentStorage(json_pref_store_.get());
169 } 186 }
170 187
171 // Currently (circa M39) enabling QUIC requires setting probability threshold. 188 // Currently (circa M39) enabling QUIC requires setting probability threshold.
172 if (config->enable_quic) { 189 if (config->enable_quic) {
173 context_->http_server_properties() 190 context_->http_server_properties()
174 ->SetAlternativeServiceProbabilityThreshold(0.0f); 191 ->SetAlternativeServiceProbabilityThreshold(0.0f);
175 for (auto hint = config->quic_hints.begin(); 192 for (auto hint = config->quic_hints.begin();
176 hint != config->quic_hints.end(); ++hint) { 193 hint != config->quic_hints.end(); ++hint) {
177 const URLRequestContextConfig::QuicHint& quic_hint = **hint; 194 const URLRequestContextConfig::QuicHint& quic_hint = **hint;
178 if (quic_hint.host.empty()) { 195 if (quic_hint.host.empty()) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 } 353 }
337 354
338 static jint SetMinLogLevel(JNIEnv* env, jclass jcaller, jint jlog_level) { 355 static jint SetMinLogLevel(JNIEnv* env, jclass jcaller, jint jlog_level) {
339 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel()); 356 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel());
340 // MinLogLevel is global, shared by all URLRequestContexts. 357 // MinLogLevel is global, shared by all URLRequestContexts.
341 logging::SetMinLogLevel(static_cast<int>(jlog_level)); 358 logging::SetMinLogLevel(static_cast<int>(jlog_level));
342 return old_log_level; 359 return old_log_level;
343 } 360 }
344 361
345 } // namespace cronet 362 } // namespace cronet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698