session: api to flush DOMStorage data
authorRobo <hop2deep@gmail.com>
Tue, 12 Jan 2016 15:28:12 +0000 (20:58 +0530)
committerRobo <hop2deep@gmail.com>
Wed, 13 Jan 2016 03:26:00 +0000 (08:56 +0530)
atom/browser/api/atom_api_session.cc
atom/browser/api/atom_api_session.h
docs/api/session.md

index f71b28c..f9e7148 100644 (file)
@@ -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)
index 0034b14..c631670 100644 (file)
@@ -64,6 +64,7 @@ class Session: public mate::TrackableObject<Session>,
   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);
index a8a55b5..9dd2bca 100644 (file)
@@ -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