| 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/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 13 #include "base/values.h" | 14 #include "base/values.h" |
| 14 #include "components/cronet/url_request_context_config.h" | 15 #include "components/cronet/url_request_context_config.h" |
| 15 #include "jni/CronetUrlRequestContext_jni.h" | 16 #include "jni/CronetUrlRequestContext_jni.h" |
| 16 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
| 17 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
| 18 #include "net/base/net_log_logger.h" | 19 #include "net/base/net_log_logger.h" |
| 19 #include "net/base/network_delegate_impl.h" | 20 #include "net/base/network_delegate_impl.h" |
| 20 #include "net/http/http_auth_handler_factory.h" | 21 #include "net/http/http_auth_handler_factory.h" |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 } | 282 } |
| 282 | 283 |
| 283 void CronetURLRequestContextAdapter::StartNetLogToFileOnNetworkThread( | 284 void CronetURLRequestContextAdapter::StartNetLogToFileOnNetworkThread( |
| 284 const std::string& file_name) { | 285 const std::string& file_name) { |
| 285 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); | 286 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); |
| 286 // Do nothing if already logging to a file. | 287 // Do nothing if already logging to a file. |
| 287 if (net_log_logger_) | 288 if (net_log_logger_) |
| 288 return; | 289 return; |
| 289 | 290 |
| 290 base::FilePath file_path(file_name); | 291 base::FilePath file_path(file_name); |
| 291 FILE* file = base::OpenFile(file_path, "w"); | 292 base::ScopedFILE file(base::OpenFile(file_path, "w")); |
| 292 if (!file) | 293 if (!file) |
| 293 return; | 294 return; |
| 294 | 295 |
| 295 scoped_ptr<base::Value> constants(net::NetLogLogger::GetConstants()); | 296 net_log_logger_.reset(new net::NetLogLogger()); |
| 296 net_log_logger_.reset(new net::NetLogLogger(file, *constants)); | 297 net_log_logger_->StartObserving(context_->net_log(), file.Pass(), nullptr, |
| 297 net_log_logger_->StartObserving(context_->net_log()); | 298 context_.get()); |
| 298 } | 299 } |
| 299 | 300 |
| 300 void CronetURLRequestContextAdapter::StopNetLogOnNetworkThread() { | 301 void CronetURLRequestContextAdapter::StopNetLogOnNetworkThread() { |
| 301 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); | 302 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); |
| 302 if (net_log_logger_) { | 303 if (net_log_logger_) { |
| 303 net_log_logger_->StopObserving(); | 304 net_log_logger_->StopObserving(); |
| 304 net_log_logger_.reset(); | 305 net_log_logger_.reset(); |
| 305 } | 306 } |
| 306 } | 307 } |
| 307 | 308 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 324 } | 325 } |
| 325 | 326 |
| 326 static jint SetMinLogLevel(JNIEnv* env, jclass jcaller, jint jlog_level) { | 327 static jint SetMinLogLevel(JNIEnv* env, jclass jcaller, jint jlog_level) { |
| 327 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel()); | 328 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel()); |
| 328 // MinLogLevel is global, shared by all URLRequestContexts. | 329 // MinLogLevel is global, shared by all URLRequestContexts. |
| 329 logging::SetMinLogLevel(static_cast<int>(jlog_level)); | 330 logging::SetMinLogLevel(static_cast<int>(jlog_level)); |
| 330 return old_log_level; | 331 return old_log_level; |
| 331 } | 332 } |
| 332 | 333 |
| 333 } // namespace cronet | 334 } // namespace cronet |
| OLD | NEW |