| 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" |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 271 |
| 272 void URLRequestContextAdapter::StopNetLog() { | 272 void URLRequestContextAdapter::StopNetLog() { |
| 273 PostTaskToNetworkThread( | 273 PostTaskToNetworkThread( |
| 274 FROM_HERE, base::Bind(&URLRequestContextAdapter::StopNetLogHelper, this)); | 274 FROM_HERE, base::Bind(&URLRequestContextAdapter::StopNetLogHelper, this)); |
| 275 } | 275 } |
| 276 | 276 |
| 277 void URLRequestContextAdapter::StartNetLogToFileHelper( | 277 void URLRequestContextAdapter::StartNetLogToFileHelper( |
| 278 const std::string& file_name) { | 278 const std::string& file_name) { |
| 279 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); | 279 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); |
| 280 // Do nothing if already logging to a file. | 280 // Do nothing if already logging to a file. |
| 281 if (net_log_logger_) | 281 if (write_to_file_observer_) |
| 282 return; | 282 return; |
| 283 | 283 |
| 284 base::FilePath file_path(file_name); | 284 base::FilePath file_path(file_name); |
| 285 base::ScopedFILE file(base::OpenFile(file_path, "w")); | 285 base::ScopedFILE file(base::OpenFile(file_path, "w")); |
| 286 if (!file) | 286 if (!file) |
| 287 return; | 287 return; |
| 288 | 288 |
| 289 net_log_logger_.reset(new net::WriteToFileNetLogObserver()); | 289 write_to_file_observer_.reset(new net::WriteToFileNetLogObserver()); |
| 290 net_log_logger_->StartObserving(context_->net_log(), file.Pass(), nullptr, | 290 write_to_file_observer_->StartObserving(context_->net_log(), file.Pass(), |
| 291 context_.get()); | 291 nullptr, context_.get()); |
| 292 } | 292 } |
| 293 | 293 |
| 294 void URLRequestContextAdapter::StopNetLogHelper() { | 294 void URLRequestContextAdapter::StopNetLogHelper() { |
| 295 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); | 295 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); |
| 296 if (net_log_logger_) { | 296 if (write_to_file_observer_) { |
| 297 net_log_logger_->StopObserving(context_.get()); | 297 write_to_file_observer_->StopObserving(context_.get()); |
| 298 net_log_logger_.reset(); | 298 write_to_file_observer_.reset(); |
| 299 } | 299 } |
| 300 } | 300 } |
| 301 | 301 |
| 302 void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) { | 302 void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) { |
| 303 VLOG(2) << "Net log entry: type=" << entry.type() | 303 VLOG(2) << "Net log entry: type=" << entry.type() |
| 304 << ", source=" << entry.source().type << ", phase=" << entry.phase(); | 304 << ", source=" << entry.source().type << ", phase=" << entry.phase(); |
| 305 } | 305 } |
| 306 | 306 |
| 307 } // namespace cronet | 307 } // namespace cronet |
| OLD | NEW |