Add BrowserContext::GetRequestContext

This commit is contained in:
Cheng Zhao 2016-07-04 15:29:43 +09:00
parent c1b07b3da9
commit 4afa3f7206
2 changed files with 14 additions and 6 deletions

View file

@ -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<URLRequestContextGetter*>(
GetDefaultStoragePartition(this)->GetURLRequestContext());
}
net::URLRequestContextGetter* BrowserContext::CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector protocol_interceptors) {

View file

@ -38,6 +38,9 @@ class BrowserContext : public base::RefCounted<BrowserContext>,
static scoped_refptr<BrowserContext> 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<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
const base::FilePath& partition_path) override;