| 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/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "components/cronet/url_request_context_config.h" | 14 #include "components/cronet/url_request_context_config.h" |
| 15 #include "net/android/network_change_notifier_factory_android.h" | 15 #include "net/android/network_change_notifier_factory_android.h" |
| 16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 17 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
| 18 #include "net/base/network_change_notifier.h" | 18 #include "net/base/network_change_notifier.h" |
| 19 #include "net/base/network_delegate_impl.h" | 19 #include "net/base/network_delegate_impl.h" |
| 20 #include "net/cert/cert_verifier.h" | 20 #include "net/cert/cert_verifier.h" |
| 21 #include "net/http/http_auth_handler_factory.h" | 21 #include "net/http/http_auth_handler_factory.h" |
| 22 #include "net/http/http_network_layer.h" | 22 #include "net/http/http_network_layer.h" |
| 23 #include "net/http/http_server_properties.h" | 23 #include "net/http/http_server_properties.h" |
| 24 #include "net/log/net_log_logger.h" | 24 #include "net/log/write_to_file_net_log_observer.h" |
| 25 #include "net/proxy/proxy_service.h" | 25 #include "net/proxy/proxy_service.h" |
| 26 #include "net/ssl/ssl_config_service_defaults.h" | 26 #include "net/ssl/ssl_config_service_defaults.h" |
| 27 #include "net/url_request/static_http_user_agent_settings.h" | 27 #include "net/url_request/static_http_user_agent_settings.h" |
| 28 #include "net/url_request/url_request_context_builder.h" | 28 #include "net/url_request/url_request_context_builder.h" |
| 29 #include "net/url_request/url_request_context_storage.h" | 29 #include "net/url_request/url_request_context_storage.h" |
| 30 #include "net/url_request/url_request_job_factory_impl.h" | 30 #include "net/url_request/url_request_job_factory_impl.h" |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 class BasicNetworkDelegate : public net::NetworkDelegateImpl { | 34 class BasicNetworkDelegate : public net::NetworkDelegateImpl { |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); | 278 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); |
| 279 // Do nothing if already logging to a file. | 279 // Do nothing if already logging to a file. |
| 280 if (net_log_logger_) | 280 if (net_log_logger_) |
| 281 return; | 281 return; |
| 282 | 282 |
| 283 base::FilePath file_path(file_name); | 283 base::FilePath file_path(file_name); |
| 284 base::ScopedFILE file(base::OpenFile(file_path, "w")); | 284 base::ScopedFILE file(base::OpenFile(file_path, "w")); |
| 285 if (!file) | 285 if (!file) |
| 286 return; | 286 return; |
| 287 | 287 |
| 288 net_log_logger_.reset(new net::NetLogLogger()); | 288 net_log_logger_.reset(new net::WriteToFileNetLogObserver()); |
| 289 net_log_logger_->StartObserving(context_->net_log(), file.Pass(), nullptr, | 289 net_log_logger_->StartObserving(context_->net_log(), file.Pass(), nullptr, |
| 290 context_.get()); | 290 context_.get()); |
| 291 } | 291 } |
| 292 | 292 |
| 293 void URLRequestContextAdapter::StopNetLogHelper() { | 293 void URLRequestContextAdapter::StopNetLogHelper() { |
| 294 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); | 294 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); |
| 295 if (net_log_logger_) { | 295 if (net_log_logger_) { |
| 296 net_log_logger_->StopObserving(context_.get()); | 296 net_log_logger_->StopObserving(context_.get()); |
| 297 net_log_logger_.reset(); | 297 net_log_logger_.reset(); |
| 298 } | 298 } |
| 299 } | 299 } |
| 300 | 300 |
| 301 void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) { | 301 void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) { |
| 302 VLOG(2) << "Net log entry: type=" << entry.type() | 302 VLOG(2) << "Net log entry: type=" << entry.type() |
| 303 << ", source=" << entry.source().type << ", phase=" << entry.phase(); | 303 << ", source=" << entry.source().type << ", phase=" << entry.phase(); |
| 304 } | 304 } |
| 305 | 305 |
| 306 } // namespace cronet | 306 } // namespace cronet |
| OLD | NEW |