Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 14 #include "base/prefs/pref_filter.h" | |
| 14 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "components/cronet/url_request_context_config.h" | 17 #include "components/cronet/url_request_context_config.h" |
| 17 #include "jni/CronetUrlRequestContext_jni.h" | 18 #include "jni/CronetUrlRequestContext_jni.h" |
| 18 #include "net/base/load_flags.h" | 19 #include "net/base/load_flags.h" |
| 19 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
| 20 #include "net/base/network_delegate_impl.h" | 21 #include "net/base/network_delegate_impl.h" |
| 21 #include "net/http/http_auth_handler_factory.h" | 22 #include "net/http/http_auth_handler_factory.h" |
| 22 #include "net/log/write_to_file_net_log_observer.h" | 23 #include "net/log/write_to_file_net_log_observer.h" |
| 23 #include "net/proxy/proxy_service.h" | 24 #include "net/proxy/proxy_service.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 data_reduction_proxy_->CreateNetworkDelegate(network_delegate.Pass()); | 179 data_reduction_proxy_->CreateNetworkDelegate(network_delegate.Pass()); |
| 179 ScopedVector<net::URLRequestInterceptor> interceptors; | 180 ScopedVector<net::URLRequestInterceptor> interceptors; |
| 180 interceptors.push_back(data_reduction_proxy_->CreateInterceptor()); | 181 interceptors.push_back(data_reduction_proxy_->CreateInterceptor()); |
| 181 context_builder.SetInterceptors(interceptors.Pass()); | 182 context_builder.SetInterceptors(interceptors.Pass()); |
| 182 } | 183 } |
| 183 #endif // defined(DATA_REDUCTION_PROXY_SUPPORT) | 184 #endif // defined(DATA_REDUCTION_PROXY_SUPPORT) |
| 184 context_builder.set_network_delegate(network_delegate.release()); | 185 context_builder.set_network_delegate(network_delegate.release()); |
| 185 context_builder.set_net_log(net_log.release()); | 186 context_builder.set_net_log(net_log.release()); |
| 186 context_builder.set_proxy_config_service(proxy_config_service_.release()); | 187 context_builder.set_proxy_config_service(proxy_config_service_.release()); |
| 187 config->ConfigureURLRequestContextBuilder(&context_builder); | 188 config->ConfigureURLRequestContextBuilder(&context_builder); |
| 189 | |
| 190 // Set up pref file if storage path is specified. | |
| 191 if (!config->storage_path.empty()) { | |
|
mmenke
2015/05/26 19:34:40
Suggest checking if sdch is enabled...Could get ug
xunjieli
2015/05/26 20:28:28
Done. I know HttpServerProperties will use the sam
mmenke
2015/05/27 14:40:43
That was a type...my == many (For some reason, a d
mmenke
2015/05/27 14:41:31
type == typo (Case in point...)
| |
| 192 base::FilePath filepath(config->storage_path); | |
| 193 filepath = filepath.Append(FILE_PATH_LITERAL("local_prefs.json")); | |
| 194 if (!file_thread_) { | |
|
mmenke
2015/05/26 19:34:40
Suggest a method GetFileThread, which creates it i
xunjieli
2015/05/26 20:28:28
Done.
| |
| 195 file_thread_.reset(new base::Thread("Network File Thread")); | |
| 196 file_thread_->Start(); | |
| 197 } | |
| 198 json_pref_store_ = new JsonPrefStore(filepath, file_thread_->task_runner(), | |
| 199 scoped_ptr<PrefFilter>()); | |
| 200 json_pref_store_->ReadPrefsAsync(nullptr); | |
| 201 context_builder.SetFileTaskRunner(file_thread_->task_runner()); | |
| 202 } | |
| 203 | |
| 188 context_.reset(context_builder.Build()); | 204 context_.reset(context_builder.Build()); |
| 189 | 205 |
| 190 default_load_flags_ = net::LOAD_DO_NOT_SAVE_COOKIES | | 206 default_load_flags_ = net::LOAD_DO_NOT_SAVE_COOKIES | |
| 191 net::LOAD_DO_NOT_SEND_COOKIES; | 207 net::LOAD_DO_NOT_SEND_COOKIES; |
| 192 if (config->load_disable_cache) | 208 if (config->load_disable_cache) |
| 193 default_load_flags_ |= net::LOAD_DISABLE_CACHE; | 209 default_load_flags_ |= net::LOAD_DISABLE_CACHE; |
| 194 | 210 |
| 195 if (config->enable_sdch) { | 211 if (config->enable_sdch) { |
| 196 DCHECK(context_->sdch_manager()); | 212 DCHECK(context_->sdch_manager()); |
| 197 sdch_owner_.reset( | 213 sdch_owner_.reset( |
| 198 new net::SdchOwner(context_->sdch_manager(), context_.get())); | 214 new net::SdchOwner(context_->sdch_manager(), context_.get())); |
| 215 if (json_pref_store_) | |
| 216 sdch_owner_->EnablePersistentStorage(json_pref_store_.get()); | |
| 199 } | 217 } |
| 200 | 218 |
| 201 // Currently (circa M39) enabling QUIC requires setting probability threshold. | 219 // Currently (circa M39) enabling QUIC requires setting probability threshold. |
| 202 if (config->enable_quic) { | 220 if (config->enable_quic) { |
| 203 context_->http_server_properties() | 221 context_->http_server_properties() |
| 204 ->SetAlternativeServiceProbabilityThreshold(0.0f); | 222 ->SetAlternativeServiceProbabilityThreshold(0.0f); |
| 205 for (auto hint = config->quic_hints.begin(); | 223 for (auto hint = config->quic_hints.begin(); |
| 206 hint != config->quic_hints.end(); ++hint) { | 224 hint != config->quic_hints.end(); ++hint) { |
| 207 const URLRequestContextConfig::QuicHint& quic_hint = **hint; | 225 const URLRequestContextConfig::QuicHint& quic_hint = **hint; |
| 208 if (quic_hint.host.empty()) { | 226 if (quic_hint.host.empty()) { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 } | 388 } |
| 371 | 389 |
| 372 static jint SetMinLogLevel(JNIEnv* env, jclass jcaller, jint jlog_level) { | 390 static jint SetMinLogLevel(JNIEnv* env, jclass jcaller, jint jlog_level) { |
| 373 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel()); | 391 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel()); |
| 374 // MinLogLevel is global, shared by all URLRequestContexts. | 392 // MinLogLevel is global, shared by all URLRequestContexts. |
| 375 logging::SetMinLogLevel(static_cast<int>(jlog_level)); | 393 logging::SetMinLogLevel(static_cast<int>(jlog_level)); |
| 376 return old_log_level; | 394 return old_log_level; |
| 377 } | 395 } |
| 378 | 396 |
| 379 } // namespace cronet | 397 } // namespace cronet |
| OLD | NEW |