create netlog for devtoolsnetlogobserver
This commit is contained in:
parent
681e868a5b
commit
7496cb29fe
7 changed files with 44 additions and 31 deletions
|
@ -80,6 +80,10 @@ void BrowserClient::GetAdditionalAllowedSchemesForFileSystem(
|
||||||
additional_schemes->push_back(content::kChromeUIScheme);
|
additional_schemes->push_back(content::kChromeUIScheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
net::NetLog* BrowserClient::GetNetLog() {
|
||||||
|
return browser_context()->GetNetLog();
|
||||||
|
}
|
||||||
|
|
||||||
base::FilePath BrowserClient::GetDefaultDownloadDirectory() {
|
base::FilePath BrowserClient::GetDefaultDownloadDirectory() {
|
||||||
// ~/Downloads
|
// ~/Downloads
|
||||||
base::FilePath path;
|
base::FilePath path;
|
||||||
|
|
|
@ -43,6 +43,7 @@ class BrowserClient : public content::ContentBrowserClient {
|
||||||
content::PlatformNotificationService* GetPlatformNotificationService() override;
|
content::PlatformNotificationService* GetPlatformNotificationService() override;
|
||||||
void GetAdditionalAllowedSchemesForFileSystem(
|
void GetAdditionalAllowedSchemesForFileSystem(
|
||||||
std::vector<std::string>* additional_schemes) override;
|
std::vector<std::string>* additional_schemes) override;
|
||||||
|
net::NetLog* GetNetLog() override;
|
||||||
base::FilePath GetDefaultDownloadDirectory() override;
|
base::FilePath GetDefaultDownloadDirectory() override;
|
||||||
content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
|
content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,10 @@ net::URLRequestContextGetter* BrowserContext::CreateRequestContext(
|
||||||
return url_request_getter_.get();
|
return url_request_getter_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
net::NetLog* BrowserContext::GetNetLog() {
|
||||||
|
return url_request_getter_->net_log();
|
||||||
|
}
|
||||||
|
|
||||||
net::NetworkDelegate* BrowserContext::CreateNetworkDelegate() {
|
net::NetworkDelegate* BrowserContext::CreateNetworkDelegate() {
|
||||||
return new NetworkDelegate;
|
return new NetworkDelegate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ class BrowserContext : public content::BrowserContext,
|
||||||
net::URLRequestContextGetter* CreateRequestContext(
|
net::URLRequestContextGetter* CreateRequestContext(
|
||||||
content::ProtocolHandlerMap* protocol_handlers,
|
content::ProtocolHandlerMap* protocol_handlers,
|
||||||
content::URLRequestInterceptorScopedVector protocol_interceptors);
|
content::URLRequestInterceptorScopedVector protocol_interceptors);
|
||||||
|
net::NetLog* GetNetLog();
|
||||||
|
|
||||||
net::URLRequestContextGetter* url_request_context_getter() const {
|
net::URLRequestContextGetter* url_request_context_getter() const {
|
||||||
return url_request_getter_.get();
|
return url_request_getter_.get();
|
||||||
|
|
|
@ -36,6 +36,7 @@ NetLog::NetLog(net::URLRequestContext* context)
|
||||||
: added_events_(false),
|
: added_events_(false),
|
||||||
context_(context) {
|
context_(context) {
|
||||||
auto command_line = base::CommandLine::ForCurrentProcess();
|
auto command_line = base::CommandLine::ForCurrentProcess();
|
||||||
|
if (command_line->HasSwitch(switches::kLogNetLog)) {
|
||||||
base::FilePath log_path =
|
base::FilePath log_path =
|
||||||
command_line->GetSwitchValuePath(switches::kLogNetLog);
|
command_line->GetSwitchValuePath(switches::kLogNetLog);
|
||||||
|
|
||||||
|
@ -66,14 +67,17 @@ NetLog::NetLog(net::URLRequestContext* context)
|
||||||
|
|
||||||
DeprecatedAddObserver(this, net::NetLog::LogLevel::LOG_STRIP_PRIVATE_DATA);
|
DeprecatedAddObserver(this, net::NetLog::LogLevel::LOG_STRIP_PRIVATE_DATA);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NetLog::~NetLog() {
|
NetLog::~NetLog() {
|
||||||
|
if (log_file_) {
|
||||||
DeprecatedRemoveObserver(this);
|
DeprecatedRemoveObserver(this);
|
||||||
|
|
||||||
// Ending events array.
|
// Ending events array.
|
||||||
fprintf(log_file_.get(), "]}");
|
fprintf(log_file_.get(), "]}");
|
||||||
log_file_.reset();
|
log_file_.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetLog::OnAddEntry(const net::NetLog::Entry& entry) {
|
void NetLog::OnAddEntry(const net::NetLog::Entry& entry) {
|
||||||
|
|
|
@ -150,10 +150,8 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
|
||||||
url_request_context_.reset(new net::URLRequestContext);
|
url_request_context_.reset(new net::URLRequestContext);
|
||||||
|
|
||||||
// --log-net-log
|
// --log-net-log
|
||||||
if (command_line.HasSwitch(switches::kLogNetLog)) {
|
|
||||||
net_log_.reset(new NetLog(url_request_context_.get()));
|
net_log_.reset(new NetLog(url_request_context_.get()));
|
||||||
url_request_context_->set_net_log(net_log_.get());
|
url_request_context_->set_net_log(net_log_.get());
|
||||||
}
|
|
||||||
|
|
||||||
network_delegate_.reset(delegate_->CreateNetworkDelegate());
|
network_delegate_.reset(delegate_->CreateNetworkDelegate());
|
||||||
url_request_context_->set_network_delegate(network_delegate_.get());
|
url_request_context_->set_network_delegate(network_delegate_.get());
|
||||||
|
|
|
@ -57,6 +57,7 @@ class URLRequestContextGetter : public net::URLRequestContextGetter {
|
||||||
scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const override;
|
scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const override;
|
||||||
|
|
||||||
net::HostResolver* host_resolver();
|
net::HostResolver* host_resolver();
|
||||||
|
net::NetLog* net_log() { return net_log_.get(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Delegate* delegate_;
|
Delegate* delegate_;
|
||||||
|
|
Loading…
Reference in a new issue