From 4afa3f7206e64f4d4984e9c30da35a20cb355393 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 4 Jul 2016 15:29:43 +0900 Subject: [PATCH] Add BrowserContext::GetRequestContext --- brightray/browser/browser_context.cc | 17 +++++++++++------ brightray/browser/browser_context.h | 3 +++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/brightray/browser/browser_context.cc b/brightray/browser/browser_context.cc index 4138b8e0f894..15b45ae2db01 100644 --- a/brightray/browser/browser_context.cc +++ b/brightray/browser/browser_context.cc @@ -115,6 +115,12 @@ BrowserContext::BrowserContext(const std::string& partition, bool in_memory) content::BrowserContext::Initialize(this, path_); } +BrowserContext::~BrowserContext() { + BrowserThread::DeleteSoon(BrowserThread::IO, + FROM_HERE, + resource_context_.release()); +} + void BrowserContext::InitPrefs() { auto prefs_path = GetPath().Append(FILE_PATH_LITERAL("Preferences")); PrefServiceFactory prefs_factory; @@ -129,16 +135,15 @@ void BrowserContext::InitPrefs() { prefs_ = prefs_factory.Create(registry.get()); } -BrowserContext::~BrowserContext() { - BrowserThread::DeleteSoon(BrowserThread::IO, - FROM_HERE, - resource_context_.release()); -} - void BrowserContext::RegisterInternalPrefs(PrefRegistrySimple* registry) { InspectableWebContentsImpl::RegisterPrefs(registry); } +URLRequestContextGetter* BrowserContext::GetRequestContext() { + return static_cast( + GetDefaultStoragePartition(this)->GetURLRequestContext()); +} + net::URLRequestContextGetter* BrowserContext::CreateRequestContext( content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector protocol_interceptors) { diff --git a/brightray/browser/browser_context.h b/brightray/browser/browser_context.h index fb816b79b528..bda4f3a9e4e3 100644 --- a/brightray/browser/browser_context.h +++ b/brightray/browser/browser_context.h @@ -38,6 +38,9 @@ class BrowserContext : public base::RefCounted, static scoped_refptr Create( const std::string& partition, bool in_memory); + // Get the request context, if there is no one, create it. + URLRequestContextGetter* GetRequestContext(); + // content::BrowserContext: std::unique_ptr CreateZoomLevelDelegate( const base::FilePath& partition_path) override;