diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-19 20:36:59 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-19 20:36:59 +0000 |
commit | 60e523306cb72ee07a359f82a1c85bb063ac5d6f (patch) | |
tree | e658dbcc38cd95f16de44e03dd72f9c25542b44a /webkit | |
parent | 29793d41959c3b820ba63d7ecdd6e6eb0de068fe (diff) | |
download | chromium_src-60e523306cb72ee07a359f82a1c85bb063ac5d6f.zip chromium_src-60e523306cb72ee07a359f82a1c85bb063ac5d6f.tar.gz chromium_src-60e523306cb72ee07a359f82a1c85bb063ac5d6f.tar.bz2 |
Fixup the DomStorage IPC messsages.
- make OpenStorageArea async
- use GURL to represent origins instead of strings
- consistently use 'connection_id'
- send DomStorage event messages to the originating renderer too
(these are dropped on the floor on that side pending additional
webkit/webcore changes)
- include the src connection_id for DomStorage event message that
originated in the destination renderer
Review URL: https://chromiumcodereview.appspot.com/10116007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133051 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/dom_storage/dom_storage_host.cc | 21 | ||||
-rw-r--r-- | webkit/dom_storage/dom_storage_host.h | 4 | ||||
-rw-r--r-- | webkit/tools/test_shell/simple_dom_storage_system.cc | 9 | ||||
-rw-r--r-- | webkit/tools/test_shell/simple_dom_storage_system.h | 1 |
4 files changed, 19 insertions, 16 deletions
diff --git a/webkit/dom_storage/dom_storage_host.cc b/webkit/dom_storage/dom_storage_host.cc index cb119e2..2e4ee56 100644 --- a/webkit/dom_storage/dom_storage_host.cc +++ b/webkit/dom_storage/dom_storage_host.cc @@ -13,8 +13,7 @@ namespace dom_storage { DomStorageHost::DomStorageHost(DomStorageContext* context) - : last_connection_id_(0), - context_(context) { + : context_(context) { } DomStorageHost::~DomStorageHost() { @@ -24,19 +23,19 @@ DomStorageHost::~DomStorageHost() { connections_.clear(); // Clear prior to releasing the context_ } -// TODO(michaeln): have the caller pass in the 'connection_id' value -// instead of generating them here, avoids a sync ipc on open. -int DomStorageHost::OpenStorageArea(int namespace_id, const GURL& origin) { +bool DomStorageHost::OpenStorageArea(int connection_id, int namespace_id, + const GURL& origin) { + DCHECK(!GetOpenArea(connection_id)); + if (GetOpenArea(connection_id)) + return false; // Indicates the renderer gave us very bad data. NamespaceAndArea references; references.namespace_ = context_->GetStorageNamespace(namespace_id); if (!references.namespace_) - return kInvalidAreaId; + return true; // TODO(michaeln): investigate returning false here references.area_ = references.namespace_->OpenStorageArea(origin); - if (!references.area_) - return kInvalidAreaId; - int id = ++last_connection_id_; - connections_[id] = references; - return id; + DCHECK(references.area_); + connections_[connection_id] = references; + return true; } void DomStorageHost::CloseStorageArea(int connection_id) { diff --git a/webkit/dom_storage/dom_storage_host.h b/webkit/dom_storage/dom_storage_host.h index e503686..49efb7d 100644 --- a/webkit/dom_storage/dom_storage_host.h +++ b/webkit/dom_storage/dom_storage_host.h @@ -31,7 +31,8 @@ class DomStorageHost { explicit DomStorageHost(DomStorageContext* context); ~DomStorageHost(); - int OpenStorageArea(int namespace_id, const GURL& origin); + bool OpenStorageArea(int connection_id, int namespace_id, + const GURL& origin); void CloseStorageArea(int connection_id); unsigned GetAreaLength(int connection_id); @@ -58,7 +59,6 @@ class DomStorageHost { DomStorageArea* GetOpenArea(int connection_id); - int last_connection_id_; scoped_refptr<DomStorageContext> context_; AreaMap connections_; }; diff --git a/webkit/tools/test_shell/simple_dom_storage_system.cc b/webkit/tools/test_shell/simple_dom_storage_system.cc index f9bd9bb..897ccbd 100644 --- a/webkit/tools/test_shell/simple_dom_storage_system.cc +++ b/webkit/tools/test_shell/simple_dom_storage_system.cc @@ -121,8 +121,10 @@ SimpleDomStorageSystem::AreaImpl::AreaImpl( int namespace_id, const GURL& origin) : parent_(parent), connection_id_(0) { - if (Host()) - connection_id_ = Host()->OpenStorageArea(namespace_id, origin); + if (Host()) { + connection_id_ = (parent_->next_connection_id_)++; + Host()->OpenStorageArea(connection_id_, namespace_id, origin); + } } SimpleDomStorageSystem::AreaImpl::~AreaImpl() { @@ -193,7 +195,8 @@ SimpleDomStorageSystem* SimpleDomStorageSystem::g_instance_; SimpleDomStorageSystem::SimpleDomStorageSystem() : weak_factory_(this), context_(new DomStorageContext(FilePath(), FilePath(), NULL, NULL)), - host_(new DomStorageHost(context_)) { + host_(new DomStorageHost(context_)), + next_connection_id_(1) { DCHECK(!g_instance_); g_instance_ = this; } diff --git a/webkit/tools/test_shell/simple_dom_storage_system.h b/webkit/tools/test_shell/simple_dom_storage_system.h index 96c78c4..fd03554 100644 --- a/webkit/tools/test_shell/simple_dom_storage_system.h +++ b/webkit/tools/test_shell/simple_dom_storage_system.h @@ -49,6 +49,7 @@ class SimpleDomStorageSystem { base::WeakPtrFactory<SimpleDomStorageSystem> weak_factory_; scoped_refptr<dom_storage::DomStorageContext> context_; scoped_ptr<dom_storage::DomStorageHost> host_; + int next_connection_id_; static SimpleDomStorageSystem* g_instance_; }; |