[WK2] Local storage areas should get torn down when they have no remaining references.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 May 2015 00:30:59 +0000 (00:30 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 May 2015 00:30:59 +0000 (00:30 +0000)
commit577750e0ec4028e1184b3d0c230a103250ad3da5
tree7499d26f43675cc0b3fc5f19356981849c9fabcd
parent3874d65c7f99ac05ebdbd6b495a67d833bac69ef
[WK2] Local storage areas should get torn down when they have no remaining references.
<https://webkit.org/b/143339>
<rdar://problem/20156436>

Reviewed by Darin Adler.

Source/WebCore:

Add StorageArea::securityOrigin() implementations.

* loader/EmptyClients.cpp:
* storage/StorageArea.h:

Source/WebKit:

Add StorageArea::securityOrigin() implementation.

* Storage/StorageAreaImpl.h:

Source/WebKit2:

Let StorageNamespaceImpl own its StorageAreaMaps weakly instead of through RefPtr.
Ownership is flipped so that StorageAreaMap refs the StorageNamespaceImpl instead.
This allows the StorageAreaMaps to get destroyed once all of its clients are gone.

Practically speaking, this means that the garbage collector now decides when local
storage databases can be closed, instead of us keeping them open for the lifetime
of the web process.

For session storage, it works a bit differently. In the web process, they get torn
down when their last client disappears, but they stay alive in the UI process.
If/when the web process asks the UI process to open session storage for an origin,
the UI process checks if one already exists, and if so, just updates the ID of the
old storage with the new one provided by the web process.

* UIProcess/Storage/StorageManager.cpp:
(WebKit::StorageManager::StorageArea::isSessionStorage):
(WebKit::StorageManager::createTransientLocalStorageMap):
(WebKit::StorageManager::createSessionStorageMap):
(WebKit::StorageManager::destroyStorageMap):
* WebProcess/Storage/StorageAreaImpl.cpp:
(WebKit::StorageAreaImpl::securityOrigin):
* WebProcess/Storage/StorageAreaImpl.h:
* WebProcess/Storage/StorageAreaMap.cpp:
(WebKit::StorageAreaMap::StorageAreaMap):
(WebKit::StorageAreaMap::~StorageAreaMap):
* WebProcess/Storage/StorageAreaMap.h:
(WebKit::StorageAreaMap::securityOrigin):
* WebProcess/Storage/StorageNamespaceImpl.cpp:
(WebKit::StorageNamespaceImpl::didDestroyStorageAreaMap):
(WebKit::StorageNamespaceImpl::storageArea):
* WebProcess/Storage/StorageNamespaceImpl.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184930 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/storage/StorageArea.h
Source/WebKit/ChangeLog
Source/WebKit/Storage/StorageAreaImpl.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/Storage/StorageManager.cpp
Source/WebKit2/WebProcess/Storage/StorageAreaImpl.cpp
Source/WebKit2/WebProcess/Storage/StorageAreaImpl.h
Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp
Source/WebKit2/WebProcess/Storage/StorageAreaMap.h
Source/WebKit2/WebProcess/Storage/StorageNamespaceImpl.cpp
Source/WebKit2/WebProcess/Storage/StorageNamespaceImpl.h