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/url_request_context_adapter.h" | 5 #include "components/cronet/android/url_request_context_adapter.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 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/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.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 "components/cronet/url_request_context_config.h" | 15 #include "components/cronet/url_request_context_config.h" |
| 15 #include "net/android/network_change_notifier_factory_android.h" | 16 #include "net/android/network_change_notifier_factory_android.h" |
| 16 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 17 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
| 18 #include "net/base/network_change_notifier.h" | 19 #include "net/base/network_change_notifier.h" |
| 19 #include "net/base/network_delegate_impl.h" | 20 #include "net/base/network_delegate_impl.h" |
| 20 #include "net/cert/cert_verifier.h" | 21 #include "net/cert/cert_verifier.h" |
| 21 #include "net/http/http_auth_handler_factory.h" | 22 #include "net/http/http_auth_handler_factory.h" |
| 22 #include "net/http/http_network_layer.h" | 23 #include "net/http/http_network_layer.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 | 144 |
| 144 void URLRequestContextAdapter::InitRequestContextOnNetworkThread() { | 145 void URLRequestContextAdapter::InitRequestContextOnNetworkThread() { |
| 145 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); | 146 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); |
| 146 DCHECK(config_); | 147 DCHECK(config_); |
| 147 // TODO(mmenke): Add method to have the builder enable SPDY. | 148 // TODO(mmenke): Add method to have the builder enable SPDY. |
| 148 net::URLRequestContextBuilder context_builder; | 149 net::URLRequestContextBuilder context_builder; |
| 149 context_builder.set_network_delegate(new BasicNetworkDelegate()); | 150 context_builder.set_network_delegate(new BasicNetworkDelegate()); |
| 150 context_builder.set_proxy_config_service(proxy_config_service_.get()); | 151 context_builder.set_proxy_config_service(proxy_config_service_.get()); |
| 151 config_->ConfigureURLRequestContextBuilder(&context_builder); | 152 config_->ConfigureURLRequestContextBuilder(&context_builder); |
| 152 | 153 |
| 154 // Set up pref file if storage path is specified. | |
| 155 if (!config_->storage_path.empty()) { | |
|
mmenke
2015/05/20 18:33:42
Wonder if it's really worth hooking this up to the
xunjieli
2015/05/20 21:06:12
Send out an email. If there's no strong interest,
| |
| 156 base::FilePath filepath(config_->storage_path); | |
| 157 filepath = filepath.Append(FILE_PATH_LITERAL("local_prefs_legacy.json")); | |
| 158 if (!file_thread_) { | |
| 159 file_thread_.reset(new base::Thread("Network File Thread")); | |
| 160 file_thread_->Start(); | |
| 161 } | |
| 162 json_pref_store_ = new JsonPrefStore(filepath, file_thread_->task_runner(), | |
| 163 scoped_ptr<PrefFilter>()); | |
| 164 json_pref_store_->ReadPrefsAsync(nullptr); | |
| 165 context_builder.SetFileTaskRunner(file_thread_->task_runner()); | |
| 166 } | |
| 167 | |
| 153 context_.reset(context_builder.Build()); | 168 context_.reset(context_builder.Build()); |
| 154 | 169 |
| 155 if (config_->enable_sdch) { | 170 if (config_->enable_sdch) { |
| 156 DCHECK(context_->sdch_manager()); | 171 DCHECK(context_->sdch_manager()); |
| 157 sdch_owner_.reset( | 172 sdch_owner_.reset( |
| 158 new net::SdchOwner(context_->sdch_manager(), context_.get())); | 173 new net::SdchOwner(context_->sdch_manager(), context_.get())); |
| 174 if (json_pref_store_) | |
| 175 sdch_owner_->EnablePersistentStorage(json_pref_store_.get()); | |
| 159 } | 176 } |
| 160 | 177 |
| 161 // Currently (circa M39) enabling QUIC requires setting probability threshold. | 178 // Currently (circa M39) enabling QUIC requires setting probability threshold. |
| 162 if (config_->enable_quic) { | 179 if (config_->enable_quic) { |
| 163 context_->http_server_properties() | 180 context_->http_server_properties() |
| 164 ->SetAlternativeServiceProbabilityThreshold(0.0f); | 181 ->SetAlternativeServiceProbabilityThreshold(0.0f); |
| 165 for (size_t hint = 0; hint < config_->quic_hints.size(); ++hint) { | 182 for (size_t hint = 0; hint < config_->quic_hints.size(); ++hint) { |
| 166 const URLRequestContextConfig::QuicHint& quic_hint = | 183 const URLRequestContextConfig::QuicHint& quic_hint = |
| 167 *config_->quic_hints[hint]; | 184 *config_->quic_hints[hint]; |
| 168 if (quic_hint.host.empty()) { | 185 if (quic_hint.host.empty()) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 write_to_file_observer_.reset(); | 327 write_to_file_observer_.reset(); |
| 311 } | 328 } |
| 312 } | 329 } |
| 313 | 330 |
| 314 void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) { | 331 void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) { |
| 315 VLOG(2) << "Net log entry: type=" << entry.type() | 332 VLOG(2) << "Net log entry: type=" << entry.type() |
| 316 << ", source=" << entry.source().type << ", phase=" << entry.phase(); | 333 << ", source=" << entry.source().type << ", phase=" << entry.phase(); |
| 317 } | 334 } |
| 318 | 335 |
| 319 } // namespace cronet | 336 } // namespace cronet |
| OLD | NEW |