mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-25 08:27:41 +01:00
Implement persistent localStorage with the new DOM storage backend (issue #603).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@704 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
1f42df1b61
commit
a6aded4716
@ -3,8 +3,11 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "libcef/browser_dom_storage_system.h"
|
#include "libcef/browser_dom_storage_system.h"
|
||||||
|
#include "libcef/cef_context.h"
|
||||||
|
#include "libcef/cef_thread.h"
|
||||||
|
|
||||||
#include "base/auto_reset.h"
|
#include "base/auto_reset.h"
|
||||||
|
#include "base/path_service.h"
|
||||||
#include "googleurl/src/gurl.h"
|
#include "googleurl/src/gurl.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageArea.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageArea.h"
|
||||||
@ -13,10 +16,12 @@
|
|||||||
#include "webkit/database/database_util.h"
|
#include "webkit/database/database_util.h"
|
||||||
#include "webkit/dom_storage/dom_storage_area.h"
|
#include "webkit/dom_storage/dom_storage_area.h"
|
||||||
#include "webkit/dom_storage/dom_storage_host.h"
|
#include "webkit/dom_storage/dom_storage_host.h"
|
||||||
|
#include "webkit/dom_storage/dom_storage_task_runner.h"
|
||||||
|
|
||||||
using dom_storage::DomStorageContext;
|
using dom_storage::DomStorageContext;
|
||||||
using dom_storage::DomStorageHost;
|
using dom_storage::DomStorageHost;
|
||||||
using dom_storage::DomStorageSession;
|
using dom_storage::DomStorageSession;
|
||||||
|
using dom_storage::DomStorageWorkerPoolTaskRunner;
|
||||||
using webkit_database::DatabaseUtil;
|
using webkit_database::DatabaseUtil;
|
||||||
using WebKit::WebStorageArea;
|
using WebKit::WebStorageArea;
|
||||||
using WebKit::WebStorageNamespace;
|
using WebKit::WebStorageNamespace;
|
||||||
@ -194,10 +199,30 @@ BrowserDomStorageSystem* BrowserDomStorageSystem::g_instance_;
|
|||||||
|
|
||||||
BrowserDomStorageSystem::BrowserDomStorageSystem()
|
BrowserDomStorageSystem::BrowserDomStorageSystem()
|
||||||
: weak_factory_(this),
|
: weak_factory_(this),
|
||||||
context_(new DomStorageContext(FilePath(), FilePath(), NULL, NULL)),
|
|
||||||
host_(new DomStorageHost(context_)),
|
|
||||||
area_being_processed_(NULL),
|
area_being_processed_(NULL),
|
||||||
next_connection_id_(1) {
|
next_connection_id_(1) {
|
||||||
|
FilePath local_storage_path;
|
||||||
|
FilePath cache_path(_Context->cache_path());
|
||||||
|
if (!cache_path.empty()) {
|
||||||
|
local_storage_path = cache_path.Append(FILE_PATH_LITERAL("Local Storage"));
|
||||||
|
if (!file_util::PathExists(local_storage_path) &&
|
||||||
|
!file_util::CreateDirectory(local_storage_path)) {
|
||||||
|
LOG(WARNING) << "Failed to create Local Storage directory";
|
||||||
|
local_storage_path.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
base::SequencedWorkerPool* worker_pool = _Context->blocking_pool();
|
||||||
|
|
||||||
|
context_ = new DomStorageContext(local_storage_path, FilePath(), NULL,
|
||||||
|
new DomStorageWorkerPoolTaskRunner(
|
||||||
|
worker_pool,
|
||||||
|
worker_pool->GetNamedSequenceToken("dom_storage_primary"),
|
||||||
|
worker_pool->GetNamedSequenceToken("dom_storage_commit"),
|
||||||
|
CefThread::GetMessageLoopProxyForThread(CefThread::FILE)));
|
||||||
|
|
||||||
|
host_.reset(new DomStorageHost(context_));
|
||||||
|
|
||||||
DCHECK(!g_instance_);
|
DCHECK(!g_instance_);
|
||||||
g_instance_ = this;
|
g_instance_ = this;
|
||||||
context_->AddEventObserver(this);
|
context_->AddEventObserver(this);
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "base/at_exit.h"
|
#include "base/at_exit.h"
|
||||||
#include "base/file_path.h"
|
#include "base/file_path.h"
|
||||||
#include "base/memory/ref_counted.h"
|
#include "base/memory/ref_counted.h"
|
||||||
|
#include "base/threading/sequenced_worker_pool.h"
|
||||||
|
|
||||||
class CefBrowserImpl;
|
class CefBrowserImpl;
|
||||||
class CefResourceBundleDelegate;
|
class CefResourceBundleDelegate;
|
||||||
@ -88,6 +89,12 @@ class CefContext : public CefBase {
|
|||||||
current_webviewhost_ = host;
|
current_webviewhost_ = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The SequencedWorkerPool object is managed by CefProcessUIThread.
|
||||||
|
void set_blocking_pool(base::SequencedWorkerPool* blocking_pool) {
|
||||||
|
blocking_pool_ = blocking_pool;
|
||||||
|
}
|
||||||
|
base::SequencedWorkerPool* blocking_pool() { return blocking_pool_.get(); }
|
||||||
|
|
||||||
static bool ImplementsThreadSafeReferenceCounting() { return true; }
|
static bool ImplementsThreadSafeReferenceCounting() { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -122,6 +129,8 @@ class CefContext : public CefBase {
|
|||||||
|
|
||||||
WebViewHost* current_webviewhost_;
|
WebViewHost* current_webviewhost_;
|
||||||
|
|
||||||
|
scoped_refptr<base::SequencedWorkerPool> blocking_pool_;
|
||||||
|
|
||||||
IMPLEMENT_REFCOUNTING(CefContext);
|
IMPLEMENT_REFCOUNTING(CefContext);
|
||||||
IMPLEMENT_LOCKING(CefContext);
|
IMPLEMENT_LOCKING(CefContext);
|
||||||
};
|
};
|
||||||
|
@ -100,6 +100,10 @@ void CefProcessUIThread::Init() {
|
|||||||
|
|
||||||
PlatformInit();
|
PlatformInit();
|
||||||
|
|
||||||
|
// Initialize the blocking pool.
|
||||||
|
blocking_pool_ = new base::SequencedWorkerPool(3, "BrowserBlocking");
|
||||||
|
_Context->set_blocking_pool(blocking_pool_.get());
|
||||||
|
|
||||||
// Initialize WebKit.
|
// Initialize WebKit.
|
||||||
webkit_init_ = new BrowserWebKitInit();
|
webkit_init_ = new BrowserWebKitInit();
|
||||||
|
|
||||||
@ -194,6 +198,11 @@ void CefProcessUIThread::CleanUp() {
|
|||||||
net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
|
net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
|
||||||
network_change_notifier_.reset();
|
network_change_notifier_.reset();
|
||||||
|
|
||||||
|
// Shut down the blocking pool.
|
||||||
|
_Context->set_blocking_pool(NULL);
|
||||||
|
blocking_pool_->Shutdown();
|
||||||
|
blocking_pool_ = NULL;
|
||||||
|
|
||||||
PlatformCleanUp();
|
PlatformCleanUp();
|
||||||
|
|
||||||
_Context->CleanupResourceBundle();
|
_Context->CleanupResourceBundle();
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
|
#include "base/threading/sequenced_worker_pool.h"
|
||||||
#include "net/base/network_change_notifier.h"
|
#include "net/base/network_change_notifier.h"
|
||||||
|
|
||||||
class BrowserWebKitInit;
|
class BrowserWebKitInit;
|
||||||
@ -53,6 +54,8 @@ class CefProcessUIThread
|
|||||||
|
|
||||||
scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
|
scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
|
||||||
|
|
||||||
|
scoped_refptr<base::SequencedWorkerPool> blocking_pool_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CefProcessUIThread);
|
DISALLOW_COPY_AND_ASSIGN(CefProcessUIThread);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user