diff --git a/brightray/browser/net_log.cc b/brightray/browser/net_log.cc index e4be6c70035d..7861a96ecf0a 100644 --- a/brightray/browser/net_log.cc +++ b/brightray/browser/net_log.cc @@ -21,7 +21,6 @@ base::Value* GetConstants() { // Adding client information to constants dictionary. base::DictionaryValue* client_info = new base::DictionaryValue(); - client_info->SetString("name", "Electron"); client_info->SetString("command_line", base::CommandLine::ForCurrentProcess()->GetCommandLineString()); @@ -38,21 +37,19 @@ NetLog::NetLog(net::URLRequestContext* context) : added_events_(false), context_(context) { auto command_line = base::CommandLine::ForCurrentProcess(); + base::FilePath log_path = + command_line->GetSwitchValuePath(switches::kLogNetLog); - if (command_line->HasSwitch(switches::kLogNetLog)) { - base::FilePath log_path = - command_line->GetSwitchValuePath(switches::kLogNetLog); - - #if defined(OS_WIN) - log_file_.reset(_wfopen(log_path.value().c_str(), L"w")); - #elif defined(OS_POSIX) - log_file_.reset(fopen(log_path.value().c_str(), "w")); - #endif - - if (!log_file_) - LOG(ERROR) << "Could not open file: " << log_path.value() - << "for net logging"; + #if defined(OS_WIN) + log_file_.reset(_wfopen(log_path.value().c_str(), L"w")); + #elif defined(OS_POSIX) + log_file_.reset(fopen(log_path.value().c_str(), "w")); + #endif + if (!log_file_) { + LOG(ERROR) << "Could not open file: " << log_path.value() + << "for net logging"; + } else { std::string json; base::JSONWriter::Write(GetConstants(), &json); fprintf(log_file_.get(), "{\"constants\": %s, \n", json.c_str()); diff --git a/brightray/browser/url_request_context_getter.cc b/brightray/browser/url_request_context_getter.cc index 0ab19af5217a..256ec4005d1a 100644 --- a/brightray/browser/url_request_context_getter.cc +++ b/brightray/browser/url_request_context_getter.cc @@ -148,8 +148,13 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { auto& command_line = *base::CommandLine::ForCurrentProcess(); if (!url_request_context_.get()) { url_request_context_.reset(new net::URLRequestContext); - net_log_.reset(new NetLog(url_request_context_.get())); - url_request_context_->set_net_log(net_log_.get()); + + // --log-net-log + if (command_line.HasSwitch(switches::kLogNetLog)) { + net_log_.reset(new NetLog(url_request_context_.get())); + url_request_context_->set_net_log(net_log_.get()); + } + network_delegate_.reset(delegate_->CreateNetworkDelegate()); url_request_context_->set_network_delegate(network_delegate_.get());