From 8433d94cacfe251f6351deae893250cbbf4fea9e Mon Sep 17 00:00:00 2001 From: Robo Date: Tue, 12 Jan 2016 20:58:12 +0530 Subject: [PATCH] session: api to flush DOMStorage data --- atom/browser/api/atom_api_session.cc | 7 +++++++ atom/browser/api/atom_api_session.h | 1 + docs/api/session.md | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index f71b28c1cb7..f9e71488027 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -312,6 +312,12 @@ void Session::ClearStorageData(mate::Arguments* args) { base::Time(), base::Time::Max(), callback); } +void Session::FlushStorageData() { + auto storage_partition = + content::BrowserContext::GetStoragePartition(browser_context(), nullptr); + storage_partition->Flush(); +} + void Session::SetProxy(const net::ProxyConfig& config, const base::Closure& callback) { auto getter = browser_context_->GetRequestContext(); @@ -416,6 +422,7 @@ void Session::BuildPrototype(v8::Isolate* isolate, .SetMethod("resolveProxy", &Session::ResolveProxy) .SetMethod("clearCache", &Session::ClearCache) .SetMethod("clearStorageData", &Session::ClearStorageData) + .SetMethod("flushStorageData", &Session::FlushStorageData) .SetMethod("setProxy", &Session::SetProxy) .SetMethod("setDownloadPath", &Session::SetDownloadPath) .SetMethod("enableNetworkEmulation", &Session::EnableNetworkEmulation) diff --git a/atom/browser/api/atom_api_session.h b/atom/browser/api/atom_api_session.h index 0034b148063..c631670831e 100644 --- a/atom/browser/api/atom_api_session.h +++ b/atom/browser/api/atom_api_session.h @@ -64,6 +64,7 @@ class Session: public mate::TrackableObject, void ResolveProxy(const GURL& url, ResolveProxyCallback callback); void ClearCache(const net::CompletionCallback& callback); void ClearStorageData(mate::Arguments* args); + void FlushStorageData(); void SetProxy(const net::ProxyConfig& config, const base::Closure& callback); void SetDownloadPath(const base::FilePath& path); void EnableNetworkEmulation(const mate::Dictionary& options); diff --git a/docs/api/session.md b/docs/api/session.md index a8a55b593f2..9dd2bca0ed7 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -179,6 +179,10 @@ Clears the session’s HTTP cache. Clears the data of web storages. +#### `ses.flushStorageData()` + +Writes any unwritten DOMStorage data to disk. + #### `ses.setProxy(config, callback)` * `config` Object