| 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/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 12 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 13 #include "components/cronet/url_request_context_config.h" | 14 #include "components/cronet/url_request_context_config.h" |
| 14 #include "net/android/network_change_notifier_factory_android.h" | 15 #include "net/android/network_change_notifier_factory_android.h" |
| 15 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 16 #include "net/base/net_log_logger.h" | 17 #include "net/base/net_log_logger.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" |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 } | 274 } |
| 274 | 275 |
| 275 void URLRequestContextAdapter::StartNetLogToFileHelper( | 276 void URLRequestContextAdapter::StartNetLogToFileHelper( |
| 276 const std::string& file_name) { | 277 const std::string& file_name) { |
| 277 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); | 278 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); |
| 278 // Do nothing if already logging to a file. | 279 // Do nothing if already logging to a file. |
| 279 if (net_log_logger_) | 280 if (net_log_logger_) |
| 280 return; | 281 return; |
| 281 | 282 |
| 282 base::FilePath file_path(file_name); | 283 base::FilePath file_path(file_name); |
| 283 FILE* file = base::OpenFile(file_path, "w"); | 284 base::ScopedFILE file(base::OpenFile(file_path, "w")); |
| 284 if (!file) | 285 if (!file) |
| 285 return; | 286 return; |
| 286 | 287 |
| 287 scoped_ptr<base::Value> constants(net::NetLogLogger::GetConstants()); | 288 net_log_logger_.reset(new net::NetLogLogger()); |
| 288 net_log_logger_.reset(new net::NetLogLogger(file, *constants)); | 289 net_log_logger_->StartObserving(context_->net_log(), file.Pass(), nullptr, |
| 289 net_log_logger_->StartObserving(context_->net_log()); | 290 context_.get()); |
| 290 } | 291 } |
| 291 | 292 |
| 292 void URLRequestContextAdapter::StopNetLogHelper() { | 293 void URLRequestContextAdapter::StopNetLogHelper() { |
| 293 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); | 294 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); |
| 294 if (net_log_logger_) { | 295 if (net_log_logger_) { |
| 295 net_log_logger_->StopObserving(); | 296 net_log_logger_->StopObserving(context_.get()); |
| 296 net_log_logger_.reset(); | 297 net_log_logger_.reset(); |
| 297 } | 298 } |
| 298 } | 299 } |
| 299 | 300 |
| 300 void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) { | 301 void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) { |
| 301 VLOG(2) << "Net log entry: type=" << entry.type() | 302 VLOG(2) << "Net log entry: type=" << entry.type() |
| 302 << ", source=" << entry.source().type << ", phase=" << entry.phase(); | 303 << ", source=" << entry.source().type << ", phase=" << entry.phase(); |
| 303 } | 304 } |
| 304 | 305 |
| 305 } // namespace cronet | 306 } // namespace cronet |
| OLD | NEW |