NetLog should be managed by BrowserClient

This commit is contained in:
Cheng Zhao 2016-05-23 19:02:13 +09:00
parent 4ccf4394d7
commit f5bfbada97
4 changed files with 17 additions and 12 deletions

View file

@ -84,6 +84,10 @@ void BrowserClient::GetAdditionalAllowedSchemesForFileSystem(
additional_schemes->push_back(content::kChromeUIScheme);
}
net::NetLog* BrowserClient::GetNetLog() {
return &net_log_;
}
base::FilePath BrowserClient::GetDefaultDownloadDirectory() {
// ~/Downloads
base::FilePath path;

View file

@ -5,6 +5,7 @@
#ifndef BRIGHTRAY_BROWSER_BROWSER_CLIENT_H_
#define BRIGHTRAY_BROWSER_BROWSER_CLIENT_H_
#include "browser/net_log.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/content_browser_client.h"
@ -33,13 +34,6 @@ class BrowserClient : public content::ContentBrowserClient {
callback.Run(true);
}
protected:
// Subclasses should override this to provide their own BrowserMainParts
// implementation. The lifetime of the returned instance is managed by the
// caller.
virtual BrowserMainParts* OverrideCreateBrowserMainParts(
const content::MainFunctionParams&);
// Subclasses that override this (e.g., to provide their own protocol
// handlers) should call this implementation after doing their own work.
content::BrowserMainParts* CreateBrowserMainParts(
@ -48,12 +42,21 @@ class BrowserClient : public content::ContentBrowserClient {
content::PlatformNotificationService* GetPlatformNotificationService() override;
void GetAdditionalAllowedSchemesForFileSystem(
std::vector<std::string>* additional_schemes) override;
net::NetLog* GetNetLog() override;
base::FilePath GetDefaultDownloadDirectory() override;
content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
BrowserMainParts* browser_main_parts_;
protected:
// Subclasses should override this to provide their own BrowserMainParts
// implementation. The lifetime of the returned instance is managed by the
// caller.
virtual BrowserMainParts* OverrideCreateBrowserMainParts(
const content::MainFunctionParams&);
private:
BrowserMainParts* browser_main_parts_;
NetLog net_log_;
std::unique_ptr<PlatformNotificationService> notification_service_;
std::unique_ptr<NotificationPresenter> notification_presenter_;

View file

@ -5,6 +5,7 @@
#include "browser/browser_context.h"
#include "browser/brightray_paths.h"
#include "browser/browser_client.h"
#include "browser/inspectable_web_contents_impl.h"
#include "browser/network_delegate.h"
#include "browser/permission_manager.h"
@ -145,7 +146,7 @@ net::URLRequestContextGetter* BrowserContext::CreateRequestContext(
url_request_getter_ = new URLRequestContextGetter(
this,
network_controller_handle(),
&net_log_,
static_cast<NetLog*>(BrowserClient::Get()->GetNetLog()),
GetPath(),
in_memory_,
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO),

View file

@ -7,7 +7,6 @@
#include <map>
#include "browser/net_log.h"
#include "browser/net/devtools_network_controller_handle.h"
#include "browser/permission_manager.h"
#include "browser/url_request_context_getter.h"
@ -25,7 +24,6 @@ class SpecialStoragePolicy;
namespace brightray {
class NetLog;
class PermissionManager;
class BrowserContext : public base::RefCounted<BrowserContext>,
@ -122,7 +120,6 @@ class BrowserContext : public base::RefCounted<BrowserContext>,
bool in_memory_;
DevToolsNetworkControllerHandle network_controller_handle_;
NetLog net_log_;
std::unique_ptr<ResourceContext> resource_context_;
scoped_refptr<URLRequestContextGetter> url_request_getter_;