| Index: components/cronet/ios/cronet_environment.cc
|
| diff --git a/components/cronet/ios/cronet_environment.cc b/components/cronet/ios/cronet_environment.cc
|
| index 0fef4af2e2266ab840e1b76a457f213ba763f5a6..b23b61b8b1191274fd79fb418d17e04403fad1f6 100644
|
| --- a/components/cronet/ios/cronet_environment.cc
|
| +++ b/components/cronet/ios/cronet_environment.cc
|
| @@ -146,34 +146,42 @@ void CronetEnvironment::Initialize() {
|
| g_network_change_notifier = net::NetworkChangeNotifier::Create();
|
| }
|
|
|
| -void CronetEnvironment::StartNetLog(base::FilePath::StringType file_name,
|
| +bool CronetEnvironment::StartNetLog(base::FilePath::StringType file_name,
|
| bool log_bytes) {
|
| - DCHECK(file_name.length());
|
| - PostToNetworkThread(FROM_HERE,
|
| - base::Bind(&CronetEnvironment::StartNetLogOnNetworkThread,
|
| - base::Unretained(this), file_name, log_bytes));
|
| -}
|
| + if (!file_name.length())
|
| + return false;
|
|
|
| -void CronetEnvironment::StartNetLogOnNetworkThread(
|
| - const base::FilePath::StringType& file_name,
|
| - bool log_bytes) {
|
| - DCHECK(file_name.length());
|
| - DCHECK(net_log_);
|
| + base::FilePath full_path(file_name);
|
|
|
| - if (net_log_observer_)
|
| - return;
|
| + if (!full_path.IsAbsolute()) {
|
| + if (!PathService::Get(base::DIR_HOME, &full_path))
|
| + return false;
|
|
|
| - base::FilePath files_root;
|
| - if (!PathService::Get(base::DIR_HOME, &files_root))
|
| - return;
|
| + full_path = full_path.Append(file_name);
|
| + }
|
|
|
| - base::FilePath full_path = files_root.Append(file_name);
|
| base::ScopedFILE file(base::OpenFile(full_path, "w"));
|
| if (!file) {
|
| LOG(ERROR) << "Can not start NetLog to " << full_path.value();
|
| - return;
|
| + return false;
|
| }
|
|
|
| + LOG(WARNING) << "Starting NetLog to " << full_path.value();
|
| + PostToNetworkThread(
|
| + FROM_HERE,
|
| + base::Bind(&CronetEnvironment::StartNetLogOnNetworkThread,
|
| + base::Unretained(this), base::Passed(&file), log_bytes));
|
| +
|
| + return true;
|
| +}
|
| +
|
| +void CronetEnvironment::StartNetLogOnNetworkThread(base::ScopedFILE file,
|
| + bool log_bytes) {
|
| + DCHECK(net_log_);
|
| +
|
| + if (net_log_observer_)
|
| + return;
|
| +
|
| net::NetLogCaptureMode capture_mode =
|
| log_bytes ? net::NetLogCaptureMode::IncludeSocketBytes()
|
| : net::NetLogCaptureMode::Default();
|
| @@ -182,7 +190,8 @@ void CronetEnvironment::StartNetLogOnNetworkThread(
|
| net_log_observer_->set_capture_mode(capture_mode);
|
| net_log_observer_->StartObserving(main_context_->net_log(), std::move(file),
|
| nullptr, main_context_.get());
|
| - LOG(WARNING) << "Started NetLog to " << full_path.value();
|
| +
|
| + LOG(WARNING) << "Started NetLog";
|
| }
|
|
|
| void CronetEnvironment::StopNetLog() {
|
|
|