Add cache option for session
This commit is contained in:
parent
e213e09c3e
commit
753e92c845
2 changed files with 12 additions and 5 deletions
|
@ -63,8 +63,9 @@ std::string RemoveWhitespace(const std::string& str) {
|
|||
|
||||
} // namespace
|
||||
|
||||
AtomBrowserContext::AtomBrowserContext(const std::string& partition,
|
||||
bool in_memory)
|
||||
AtomBrowserContext::AtomBrowserContext(
|
||||
const std::string& partition, bool in_memory,
|
||||
const base::DictionaryValue& options)
|
||||
: brightray::BrowserContext(partition, in_memory),
|
||||
network_delegate_(new AtomNetworkDelegate) {
|
||||
// Construct user agent string.
|
||||
|
@ -82,6 +83,10 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition,
|
|||
CHROME_VERSION_STRING);
|
||||
}
|
||||
user_agent_ = content::BuildUserAgentFromProduct(user_agent);
|
||||
|
||||
// Read options.
|
||||
use_cache_ = true;
|
||||
options.GetBoolean("cache", &use_cache_);
|
||||
}
|
||||
|
||||
AtomBrowserContext::~AtomBrowserContext() {
|
||||
|
@ -144,7 +149,7 @@ net::HttpCache::BackendFactory*
|
|||
AtomBrowserContext::CreateHttpCacheBackendFactory(
|
||||
const base::FilePath& base_path) {
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
if (command_line->HasSwitch(switches::kDisableHttpCache))
|
||||
if (!use_cache_ || command_line->HasSwitch(switches::kDisableHttpCache))
|
||||
return new NoCacheBackend;
|
||||
else
|
||||
return brightray::BrowserContext::CreateHttpCacheBackendFactory(base_path);
|
||||
|
@ -198,7 +203,7 @@ scoped_refptr<AtomBrowserContext> AtomBrowserContext::From(
|
|||
if (browser_context)
|
||||
return static_cast<AtomBrowserContext*>(browser_context.get());
|
||||
|
||||
return new AtomBrowserContext(partition, in_memory);
|
||||
return new AtomBrowserContext(partition, in_memory, options);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -48,7 +48,8 @@ class AtomBrowserContext : public brightray::BrowserContext {
|
|||
AtomNetworkDelegate* network_delegate() const { return network_delegate_; }
|
||||
|
||||
protected:
|
||||
AtomBrowserContext(const std::string& partition, bool in_memory);
|
||||
AtomBrowserContext(const std::string& partition, bool in_memory,
|
||||
const base::DictionaryValue& options);
|
||||
~AtomBrowserContext() override;
|
||||
|
||||
private:
|
||||
|
@ -56,6 +57,7 @@ class AtomBrowserContext : public brightray::BrowserContext {
|
|||
std::unique_ptr<WebViewManager> guest_manager_;
|
||||
std::unique_ptr<AtomPermissionManager> permission_manager_;
|
||||
std::string user_agent_;
|
||||
bool use_cache_;
|
||||
|
||||
// Managed by brightray::BrowserContext.
|
||||
AtomNetworkDelegate* network_delegate_;
|
||||
|
|
Loading…
Reference in a new issue