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
|
} // namespace
|
||||||
|
|
||||||
AtomBrowserContext::AtomBrowserContext(const std::string& partition,
|
AtomBrowserContext::AtomBrowserContext(
|
||||||
bool in_memory)
|
const std::string& partition, bool in_memory,
|
||||||
|
const base::DictionaryValue& options)
|
||||||
: brightray::BrowserContext(partition, in_memory),
|
: brightray::BrowserContext(partition, in_memory),
|
||||||
network_delegate_(new AtomNetworkDelegate) {
|
network_delegate_(new AtomNetworkDelegate) {
|
||||||
// Construct user agent string.
|
// Construct user agent string.
|
||||||
|
@ -82,6 +83,10 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition,
|
||||||
CHROME_VERSION_STRING);
|
CHROME_VERSION_STRING);
|
||||||
}
|
}
|
||||||
user_agent_ = content::BuildUserAgentFromProduct(user_agent);
|
user_agent_ = content::BuildUserAgentFromProduct(user_agent);
|
||||||
|
|
||||||
|
// Read options.
|
||||||
|
use_cache_ = true;
|
||||||
|
options.GetBoolean("cache", &use_cache_);
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomBrowserContext::~AtomBrowserContext() {
|
AtomBrowserContext::~AtomBrowserContext() {
|
||||||
|
@ -144,7 +149,7 @@ net::HttpCache::BackendFactory*
|
||||||
AtomBrowserContext::CreateHttpCacheBackendFactory(
|
AtomBrowserContext::CreateHttpCacheBackendFactory(
|
||||||
const base::FilePath& base_path) {
|
const base::FilePath& base_path) {
|
||||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||||
if (command_line->HasSwitch(switches::kDisableHttpCache))
|
if (!use_cache_ || command_line->HasSwitch(switches::kDisableHttpCache))
|
||||||
return new NoCacheBackend;
|
return new NoCacheBackend;
|
||||||
else
|
else
|
||||||
return brightray::BrowserContext::CreateHttpCacheBackendFactory(base_path);
|
return brightray::BrowserContext::CreateHttpCacheBackendFactory(base_path);
|
||||||
|
@ -198,7 +203,7 @@ scoped_refptr<AtomBrowserContext> AtomBrowserContext::From(
|
||||||
if (browser_context)
|
if (browser_context)
|
||||||
return static_cast<AtomBrowserContext*>(browser_context.get());
|
return static_cast<AtomBrowserContext*>(browser_context.get());
|
||||||
|
|
||||||
return new AtomBrowserContext(partition, in_memory);
|
return new AtomBrowserContext(partition, in_memory, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -48,7 +48,8 @@ class AtomBrowserContext : public brightray::BrowserContext {
|
||||||
AtomNetworkDelegate* network_delegate() const { return network_delegate_; }
|
AtomNetworkDelegate* network_delegate() const { return network_delegate_; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AtomBrowserContext(const std::string& partition, bool in_memory);
|
AtomBrowserContext(const std::string& partition, bool in_memory,
|
||||||
|
const base::DictionaryValue& options);
|
||||||
~AtomBrowserContext() override;
|
~AtomBrowserContext() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -56,6 +57,7 @@ class AtomBrowserContext : public brightray::BrowserContext {
|
||||||
std::unique_ptr<WebViewManager> guest_manager_;
|
std::unique_ptr<WebViewManager> guest_manager_;
|
||||||
std::unique_ptr<AtomPermissionManager> permission_manager_;
|
std::unique_ptr<AtomPermissionManager> permission_manager_;
|
||||||
std::string user_agent_;
|
std::string user_agent_;
|
||||||
|
bool use_cache_;
|
||||||
|
|
||||||
// Managed by brightray::BrowserContext.
|
// Managed by brightray::BrowserContext.
|
||||||
AtomNetworkDelegate* network_delegate_;
|
AtomNetworkDelegate* network_delegate_;
|
||||||
|
|
Loading…
Reference in a new issue