Don't specify URLRequestContext when starting logging
Related CL: https://codereview.chromium.org/2698143004
This commit is contained in:
parent
4412836e77
commit
0ad967c9a5
3 changed files with 10 additions and 25 deletions
|
@ -11,6 +11,7 @@
|
|||
#include "base/memory/ptr_util.h"
|
||||
#include "base/values.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "net/log/file_net_log_observer.h"
|
||||
#include "net/log/net_log_util.h"
|
||||
|
||||
namespace brightray {
|
||||
|
@ -38,30 +39,20 @@ NetLog::NetLog() {
|
|||
NetLog::~NetLog() {
|
||||
}
|
||||
|
||||
void NetLog::StartLogging(net::URLRequestContext* url_request_context) {
|
||||
void NetLog::StartLogging() {
|
||||
auto command_line = base::CommandLine::ForCurrentProcess();
|
||||
if (!command_line->HasSwitch(switches::kLogNetLog))
|
||||
return;
|
||||
|
||||
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";
|
||||
return;
|
||||
}
|
||||
|
||||
std::unique_ptr<base::Value> constants(GetConstants());
|
||||
write_to_file_observer_.StartObserving(this,
|
||||
std::move(log_file_),
|
||||
constants.get(),
|
||||
url_request_context);
|
||||
net::NetLogCaptureMode capture_mode =
|
||||
net::NetLogCaptureMode::IncludeCookiesAndCredentials();
|
||||
|
||||
std::unique_ptr<net::FileNetLogObserver> file_net_log_observer_ =
|
||||
net::FileNetLogObserver::CreateUnbounded(log_path, std::move(constants));
|
||||
file_net_log_observer_->StartObserving(this, capture_mode);
|
||||
}
|
||||
|
||||
} // namespace brightray
|
||||
|
|
|
@ -5,10 +5,7 @@
|
|||
#ifndef BRIGHTRAY_BROWSER_NET_LOG_H_
|
||||
#define BRIGHTRAY_BROWSER_NET_LOG_H_
|
||||
|
||||
#include "base/files/scoped_file.h"
|
||||
#include "net/log/net_log.h"
|
||||
#include "net/log/file_net_log_observer.h"
|
||||
#include "net/url_request/url_request_context.h"
|
||||
|
||||
namespace brightray {
|
||||
|
||||
|
@ -17,12 +14,9 @@ class NetLog : public net::NetLog {
|
|||
NetLog();
|
||||
~NetLog() override;
|
||||
|
||||
void StartLogging(net::URLRequestContext* url_request_context);
|
||||
void StartLogging();
|
||||
|
||||
private:
|
||||
base::ScopedFILE log_file_;
|
||||
net::FileNetLogObserver write_to_file_observer_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NetLog);
|
||||
};
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
|
|||
|
||||
// --log-net-log
|
||||
if (net_log_) {
|
||||
net_log_->StartLogging(url_request_context_.get());
|
||||
net_log_->StartLogging();
|
||||
url_request_context_->set_net_log(net_log_);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue