Store BrowserContext in ref-counted ptr
This commit is contained in:
parent
58fb166b0b
commit
dc1e50c62e
3 changed files with 8 additions and 4 deletions
|
@ -8,6 +8,7 @@
|
|||
#include "browser/permission_manager.h"
|
||||
#include "browser/url_request_context_getter.h"
|
||||
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
|
||||
class PrefRegistrySimple;
|
||||
|
@ -17,7 +18,8 @@ namespace brightray {
|
|||
|
||||
class PermissionManager;
|
||||
|
||||
class BrowserContext : public content::BrowserContext,
|
||||
class BrowserContext : public base::RefCounted<BrowserContext>,
|
||||
public content::BrowserContext,
|
||||
public brightray::URLRequestContextGetter::Delegate {
|
||||
public:
|
||||
BrowserContext();
|
||||
|
@ -66,6 +68,7 @@ class BrowserContext : public content::BrowserContext,
|
|||
base::FilePath GetPath() const override;
|
||||
|
||||
private:
|
||||
friend class base::RefCounted<BrowserContext>;
|
||||
class ResourceContext;
|
||||
|
||||
void RegisterInternalPrefs(PrefRegistrySimple* pref_registry);
|
||||
|
|
|
@ -120,7 +120,7 @@ void BrowserMainParts::PreMainMessageLoopStart() {
|
|||
}
|
||||
|
||||
void BrowserMainParts::PreMainMessageLoopRun() {
|
||||
browser_context_.reset(CreateBrowserContext());
|
||||
browser_context_ = CreateBrowserContext();
|
||||
browser_context_->Initialize(std::string());
|
||||
|
||||
content::WebUIControllerFactory::RegisterFactory(
|
||||
|
@ -133,7 +133,7 @@ void BrowserMainParts::PreMainMessageLoopRun() {
|
|||
}
|
||||
|
||||
void BrowserMainParts::PostMainMessageLoopRun() {
|
||||
browser_context_.reset();
|
||||
browser_context_ = nullptr;
|
||||
}
|
||||
|
||||
int BrowserMainParts::PreCreateThreads() {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#define BRIGHTRAY_BROWSER_BROWSER_MAIN_PARTS_H_
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "content/public/browser/browser_main_parts.h"
|
||||
|
||||
|
@ -55,7 +56,7 @@ class BrowserMainParts : public content::BrowserMainParts {
|
|||
void InitializeMainNib();
|
||||
#endif
|
||||
|
||||
scoped_ptr<BrowserContext> browser_context_;
|
||||
scoped_refptr<BrowserContext> browser_context_;
|
||||
scoped_ptr<devtools_http_handler::DevToolsHttpHandler> devtools_http_handler_;
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
|
|
Loading…
Reference in a new issue