Backout 70cde80fa095 & 5a903d496ab0 (bug 722857) for crashes in 646184.html

This commit is contained in:
Ed Morley 2012-05-25 12:51:32 +01:00
Родитель a494e104a5
Коммит 6ee39587c5
21 изменённых файлов: 124 добавлений и 419 удалений

Просмотреть файл

@ -16,8 +16,6 @@ _BROWSER_TEST_FILES = \
browser_console_clear.js \
browser_privatebrowsing_certexceptionsui.js \
browser_privatebrowsing_commandline_toggle.js \
browser_privatebrowsing_concurrent.js \
browser_privatebrowsing_concurrent_page.html \
browser_privatebrowsing_crh.js \
browser_privatebrowsing_fastswitch.js \
browser_privatebrowsing_findbar.js \
@ -27,9 +25,6 @@ _BROWSER_TEST_FILES = \
browser_privatebrowsing_import.js \
browser_privatebrowsing_lastpbcontextexited.js \
browser_privatebrowsing_localStorage.js \
browser_privatebrowsing_localStorage_before_after.js \
browser_privatebrowsing_localStorage_before_after_page.html \
browser_privatebrowsing_localStorage_before_after_page2.html \
browser_privatebrowsing_localStorage_page1.html \
browser_privatebrowsing_localStorage_page2.html \
browser_privatebrowsing_newwindow_stopcmd.js \

Просмотреть файл

@ -1,73 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
// Test opening two tabs that share a localStorage, but keep one in private mode.
// Ensure that values from one don't leak into the other, and that values from
// earlier private storage sessions aren't visible later.
// Step 1: create new tab, load a page that sets test=value in non-private storage
// Step 2: create a new tab, load a page that sets test2=value2 in private storage
// Step 3: load a page in the tab from step 1 that checks the value of test2 is value2 and the total count in non-private storage is 1
// Step 4: load a page in the tab from step 2 that checks the value of test is value and the total count in private storage is 1
function test() {
let prefix = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_concurrent_page.html';
waitForExplicitFinish();
gBrowser.selectedTab = gBrowser.addTab();
let non_private_tab = gBrowser.selectedBrowser;
non_private_tab.addEventListener('load', function() {
non_private_tab.removeEventListener('load', arguments.callee, true);
gBrowser.selectedTab = gBrowser.addTab();
let private_tab = gBrowser.selectedBrowser;
private_tab.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = true;
private_tab.addEventListener('load', function() {
private_tab.removeEventListener('load', arguments.callee, true);
non_private_tab.addEventListener('load', function() {
non_private_tab.removeEventListener('load', arguments.callee, true);
var elts = non_private_tab.contentWindow.document.title.split('|');
isnot(elts[0], 'value2', "public window shouldn't see private storage");
is(elts[1], '1', "public window should only see public items");
private_tab.addEventListener('load', function() {
private_tab.removeEventListener('load', arguments.callee, true);
var elts = private_tab.contentWindow.document.title.split('|');
isnot(elts[0], 'value', "private window shouldn't see public storage");
is(elts[1], '1', "private window should only see private items");
private_tab.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = false;
Components.utils.schedulePreciseGC(function() {
private_tab.addEventListener('load', function() {
private_tab.removeEventListener('load', arguments.callee, true);
var elts = private_tab.contentWindow.document.title.split('|');
isnot(elts[0], 'value2', "public window shouldn't see cleared private storage");
is(elts[1], '1', "public window should only see public items");
private_tab.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = true;
private_tab.addEventListener('load', function() {
private_tab.removeEventListener('load', arguments.callee, true);
var elts = private_tab.contentWindow.document.title.split('|');
is(elts[1], '1', "private window should only see new private items");
non_private_tab.addEventListener('load', function() {
gBrowser.removeCurrentTab();
gBrowser.removeCurrentTab();
finish();
}, true);
non_private_tab.loadURI(prefix + '?final=true');
}, true);
private_tab.loadURI(prefix + '?action=set&name=test3&value=value3');
}, true);
private_tab.loadURI(prefix + '?action=get&name=test2');
});
}, true);
private_tab.loadURI(prefix + '?action=get&name=test');
}, true);
non_private_tab.loadURI(prefix + '?action=get&name=test2');
}, true);
private_tab.loadURI(prefix + '?action=set&name=test2&value=value2');
}, true);
non_private_tab.loadURI(prefix + '?action=set&name=test&value=value&initial=true');
}

Просмотреть файл

@ -1,33 +0,0 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
var oGetVars = {};
if (window.location.search.length > 1) {
for (var aItKey, nKeyId = 0, aCouples = window.location.search.substr(1).split("&");
nKeyId < aCouples.length;
nKeyId++) {
aItKey = aCouples[nKeyId].split("=");
oGetVars[unescape(aItKey[0])] = aItKey.length > 1 ? unescape(aItKey[1]) : "";
}
}
if (oGetVars.initial == 'true') {
localStorage.clear();
}
if (oGetVars.action == 'set') {
localStorage.setItem(oGetVars.name, oGetVars.value);
document.title = localStorage.getItem(oGetVars.name) + "|" + localStorage.length;
} else if (oGetVars.action == 'get') {
document.title = localStorage.getItem(oGetVars.name) + "|" + localStorage.length;
}
if (oGetVars.final == 'true') {
localStorage.clear();
}
</script>
</head>
<body>
</body>
</html>

Просмотреть файл

@ -1,41 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
// Ensure that a storage instance used by both private and public sessions at different times does not
// allow any data to leak due to cached values.
// Step 1: Load browser_privatebrowsing_localStorage_before_after_page.html in a private tab, causing a storage
// item to exist. Close the tab.
// Step 2: Load the same page in a non-private tab, ensuring that the storage instance reports only one item
// existing.
function test() {
let prefix = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/';
waitForExplicitFinish();
// We wait for a GC to ensure that all previous PB docshells in this test suite are destroyed
// so that the PB localStorage instance is clean.
Components.utils.schedulePreciseGC(function() {
let tab = gBrowser.selectedTab = gBrowser.addTab();
let browser = gBrowser.selectedBrowser;
browser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = true;
browser.addEventListener('load', function() {
browser.removeEventListener('load', arguments.callee, true);
is(browser.contentWindow.document.title, '1', "localStorage should contain 1 item");
browser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = false;
gBrowser.selectedTab = gBrowser.addTab();
let browser2 = gBrowser.selectedBrowser;
gBrowser.removeTab(tab);
browser2.addEventListener('load', function() {
browser2.removeEventListener('load', arguments.callee, true);
is(browser2.contentWindow.document.title, 'null|0', 'localStorage should contain 0 items');
gBrowser.removeCurrentTab();
finish();
}, true);
browser2.loadURI(prefix + 'browser_privatebrowsing_localStorage_before_after_page2.html');
}, true);
browser.loadURI(prefix + 'browser_privatebrowsing_localStorage_before_after_page.html');
});
}

Просмотреть файл

@ -1,11 +0,0 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
localStorage.clear();
localStorage.setItem('zzztest', 'zzzvalue');
document.title = localStorage.length;
</script>
</head>
<body>
</body>
</html>

Просмотреть файл

@ -1,10 +0,0 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
document.title = localStorage.getItem('zzztest', 'zzzvalue') + '|' + localStorage.length;
localStorage.clear();
</script>
</head>
<body>
</body>
</html>

Просмотреть файл

@ -2400,7 +2400,7 @@ nsDocShell::GetSessionStorageForPrincipal(nsIPrincipal* aPrincipal,
if (!pistorage)
return NS_ERROR_FAILURE;
rv = pistorage->InitAsSessionStorage(aPrincipal, aDocumentURI, mInPrivateBrowsing);
rv = pistorage->InitAsSessionStorage(aPrincipal, aDocumentURI);
if (NS_FAILED(rv))
return rv;

Просмотреть файл

@ -104,7 +104,6 @@
#include "nsIHttpProtocolHandler.h"
#include "nsIJSContextStack.h"
#include "nsIJSRuntimeService.h"
#include "nsILoadContext.h"
#include "nsIMarkupDocumentViewer.h"
#include "nsIPresShell.h"
#include "nsIPrivateDOMEvent.h"
@ -2244,19 +2243,6 @@ nsGlobalWindow::SetDocShell(nsIDocShell* aDocShell)
bool docShellActive;
mDocShell->GetIsActive(&docShellActive);
mIsBackground = !docShellActive;
if (mLocalStorage) {
nsCOMPtr<nsIPrivacyTransitionObserver> obs = do_GetInterface(mLocalStorage);
if (obs) {
mDocShell->AddWeakPrivacyTransitionObserver(obs);
}
}
if (mSessionStorage) {
nsCOMPtr<nsIPrivacyTransitionObserver> obs = do_GetInterface(mSessionStorage);
if (obs) {
mDocShell->AddWeakPrivacyTransitionObserver(obs);
}
}
}
}
@ -8098,11 +8084,6 @@ nsGlobalWindow::GetSessionStorage(nsIDOMStorage ** aSessionStorage)
if (!mSessionStorage) {
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}
nsCOMPtr<nsIPrivacyTransitionObserver> obs = do_GetInterface(mSessionStorage);
if (obs) {
docShell->AddWeakPrivacyTransitionObserver(obs);
}
}
#ifdef PR_LOGGING
@ -8132,7 +8113,8 @@ nsGlobalWindow::GetLocalStorage(nsIDOMStorage ** aLocalStorage)
nsresult rv;
if (!nsDOMStorage::CanUseStorage())
bool unused;
if (!nsDOMStorage::CanUseStorage(&unused))
return NS_ERROR_DOM_SECURITY_ERR;
nsIPrincipal *principal = GetPrincipal();
@ -8148,19 +8130,10 @@ nsGlobalWindow::GetLocalStorage(nsIDOMStorage ** aLocalStorage)
mDocument->GetDocumentURI(documentURI);
}
nsIDocShell* docShell = GetDocShell();
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
rv = storageManager->GetLocalStorageForPrincipal(principal,
documentURI,
loadContext && loadContext->UsePrivateBrowsing(),
getter_AddRefs(mLocalStorage));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrivacyTransitionObserver> obs = do_GetInterface(mLocalStorage);
if (obs) {
docShell->AddWeakPrivacyTransitionObserver(obs);
}
}
NS_ADDREF(*aLocalStorage = mLocalStorage);

Просмотреть файл

@ -7,8 +7,6 @@
#include "CheckPermissionsHelper.h"
#include "nsIDOMWindow.h"
#include "nsILoadContext.h"
#include "nsIWebNavigation.h"
#include "nsIObserverService.h"
#include "nsIPermissionManager.h"
#include "nsIPrincipal.h"
@ -58,9 +56,7 @@ GetIndexedDBPermissions(const nsACString& aASCIIOrigin,
return nsIPermissionManager::ALLOW_ACTION;
}
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(webNav);
if (loadContext && loadContext->UsePrivateBrowsing()) {
if (nsDOMStorageManager::gStorageManager->InPrivateBrowsingMode()) {
// TODO Support private browsing indexedDB?
return nsIPermissionManager::DENY_ACTION;
}

Просмотреть файл

@ -50,41 +50,6 @@ function test1()
}
function test2()
{
info("creating tab");
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = true;
gBrowser.selectedBrowser.addEventListener("load", function () {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
setFinishedCallback(function(result, exception) {
ok(!result, "No database created");
is(exception, "InvalidStateError", "Correct exception");
is(getPermission(testPageURL, "indexedDB"),
Components.interfaces.nsIPermissionManager.DENY_ACTION,
"Correct permission set");
gBrowser.removeCurrentTab();
executeSoon(test3);
});
registerPopupEventHandler("popupshowing", function () {
ok(false, "prompt showing");
});
registerPopupEventHandler("popupshown", function () {
ok(false, "prompt shown");
});
registerPopupEventHandler("popuphidden", function () {
ok(false, "prompt hidden");
});
}, true);
info("loading test page: " + testPageURL);
content.location = testPageURL;
}
function test3()
{
info("creating tab");
gBrowser.selectedTab = gBrowser.addTab();

Просмотреть файл

@ -8,7 +8,7 @@
interface nsIDOMStorage;
interface nsIPrincipal;
[scriptable, uuid(1541da6c-a9fb-4a8f-af9d-4493c981491d)]
[scriptable, uuid(fd91ec36-7da8-43bb-b8f2-4b57a862a467)]
interface nsIDOMStorageManager : nsISupports
{
/**
@ -33,6 +33,5 @@ interface nsIDOMStorageManager : nsISupports
* for a single origin.
*/
nsIDOMStorage getLocalStorageForPrincipal(in nsIPrincipal aPrincipal,
in DOMString aDocumentURI,
[optional] in bool aPrivate);
in DOMString aDocumentURI);
};

Просмотреть файл

@ -29,10 +29,8 @@ public:
SessionStorage = 2
} nsDOMStorageType;
virtual nsresult InitAsSessionStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI,
bool aPrivate) = 0;
virtual nsresult InitAsLocalStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI,
bool aPrivate) = 0;
virtual nsresult InitAsSessionStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI) = 0;
virtual nsresult InitAsLocalStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI) = 0;
virtual already_AddRefed<nsIDOMStorage> Clone() = 0;
virtual already_AddRefed<nsIDOMStorage> Fork(const nsSubstring &aDocumentURI) = 0;

Просмотреть файл

@ -35,8 +35,8 @@ sync protocol PStorage
parent:
__delete__();
Init(bool useDB, bool canUseChromePersist, bool sessionOnly, bool isPrivate,
nsCString domain, nsCString scopeDBKey, nsCString quotaDomainDBKey,
Init(bool useDB, bool canUseChromePersist, bool sessionOnly, nsCString domain,
nsCString scopeDBKey, nsCString quotaDomainDBKey,
nsCString quotaETLDplus1DomainDBKey, PRUint32 storageType);
sync GetKeys(bool callerSecure)
@ -60,8 +60,6 @@ parent:
returns (nsresult rv);
sync SetSecure(nsString key, bool secure)
returns (nsresult rv);
UpdatePrivateState(bool enabled);
};
}

Просмотреть файл

@ -15,9 +15,7 @@ NS_IMPL_CYCLE_COLLECTION_1(StorageChild, mStorage)
NS_IMPL_CYCLE_COLLECTING_ADDREF(StorageChild)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(StorageChild)
NS_INTERFACE_MAP_ENTRY(nsIPrivacyTransitionObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIPrivacyTransitionObserver)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMETHODIMP_(nsrefcnt) StorageChild::Release(void)
@ -81,21 +79,21 @@ StorageChild::InitRemote()
ContentChild* child = ContentChild::GetSingleton();
AddIPDLReference();
child->SendPStorageConstructor(this, null_t());
SendInit(mUseDB, mCanUseChromePersist, mSessionOnly, mInPrivateBrowsing, mDomain, mScopeDBKey,
SendInit(mUseDB, mCanUseChromePersist, mSessionOnly, mDomain, mScopeDBKey,
mQuotaDomainDBKey, mQuotaETLDplus1DomainDBKey, mStorageType);
}
void
StorageChild::InitAsSessionStorage(nsIURI* aDomainURI, bool aPrivate)
StorageChild::InitAsSessionStorage(nsIURI* aDomainURI)
{
DOMStorageBase::InitAsSessionStorage(aDomainURI, aPrivate);
DOMStorageBase::InitAsSessionStorage(aDomainURI);
InitRemote();
}
void
StorageChild::InitAsLocalStorage(nsIURI* aDomainURI, bool aCanUseChromePersist, bool aPrivate)
StorageChild::InitAsLocalStorage(nsIURI* aDomainURI, bool aCanUseChromePersist)
{
DOMStorageBase::InitAsLocalStorage(aDomainURI, aCanUseChromePersist, aPrivate);
DOMStorageBase::InitAsLocalStorage(aDomainURI, aCanUseChromePersist);
InitRemote();
}
@ -236,16 +234,8 @@ StorageChild::CloneFrom(bool aCallerSecure, DOMStorageBase* aThat)
StorageClone clone(nsnull, other, aCallerSecure);
AddIPDLReference();
child->SendPStorageConstructor(this, clone);
SendInit(mUseDB, mCanUseChromePersist, mSessionOnly, mInPrivateBrowsing, mDomain,
mScopeDBKey, mQuotaDomainDBKey, mQuotaETLDplus1DomainDBKey, mStorageType);
return NS_OK;
}
NS_IMETHODIMP
StorageChild::PrivateModeChanged(bool enabled)
{
mInPrivateBrowsing = enabled;
SendUpdatePrivateState(enabled);
SendInit(mUseDB, mCanUseChromePersist, mSessionOnly, mDomain, mScopeDBKey,
mQuotaDomainDBKey, mQuotaETLDplus1DomainDBKey, mStorageType);
return NS_OK;
}

Просмотреть файл

@ -16,18 +16,16 @@ namespace dom {
class StorageChild : public PStorageChild
, public DOMStorageBase
, public nsSupportsWeakReference
{
public:
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(StorageChild, nsIPrivacyTransitionObserver)
NS_DECL_CYCLE_COLLECTION_CLASS(StorageChild)
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIPRIVACYTRANSITIONOBSERVER
StorageChild(nsDOMStorage* aOwner);
StorageChild(nsDOMStorage* aOwner, StorageChild& aOther);
virtual void InitAsSessionStorage(nsIURI* aDomainURI, bool aPrivate);
virtual void InitAsLocalStorage(nsIURI* aDomainURI, bool aCanUseChromePersist, bool aPrivate);
virtual void InitAsSessionStorage(nsIURI* aDomainURI);
virtual void InitAsLocalStorage(nsIURI* aDomainURI, bool aCanUseChromePersist);
virtual bool CacheStoragePermissions();

Просмотреть файл

@ -30,26 +30,18 @@ bool
StorageParent::RecvInit(const bool& aUseDB,
const bool& aCanUseChromePersist,
const bool& aSessionOnly,
const bool& aPrivate,
const nsCString& aDomain,
const nsCString& aScopeDBKey,
const nsCString& aQuotaDomainDBKey,
const nsCString& aQuotaETLDplus1DomainDBKey,
const PRUint32& aStorageType)
{
mStorage->InitFromChild(aUseDB, aCanUseChromePersist, aSessionOnly, aPrivate, aDomain,
mStorage->InitFromChild(aUseDB, aCanUseChromePersist, aSessionOnly, aDomain,
aScopeDBKey, aQuotaDomainDBKey, aQuotaETLDplus1DomainDBKey,
aStorageType);
return true;
}
bool
StorageParent::RecvUpdatePrivateState(const bool& aEnabled)
{
mStorage->PrivateModeChanged(aEnabled);
return true;
}
bool
StorageParent::RecvGetKeys(const bool& aCallerSecure, InfallibleTArray<nsString>* aKeys)
{

Просмотреть файл

@ -45,15 +45,12 @@ private:
bool RecvInit(const bool& aUseDB,
const bool& aCanUseChromePersist,
const bool& aSessionOnly,
const bool& aPrivate,
const nsCString& aDomain,
const nsCString& aScopeDBKey,
const nsCString& aQuotaDomainDBKey,
const nsCString& aQuotaETLDplus1DomainDBKey,
const PRUint32& aStorageType);
bool RecvUpdatePrivateState(const bool& aEnabled);
nsRefPtr<DOMStorageImpl> mStorage;
};

Просмотреть файл

@ -5,10 +5,8 @@
#include "StorageChild.h"
#include "StorageParent.h"
#include "mozilla/dom/ContentChild.h"
#include "nsXULAppAPI.h"
using mozilla::dom::StorageChild;
using mozilla::dom::ContentChild;
#include "prnetdb.h"
#include "nsCOMPtr.h"
@ -221,6 +219,7 @@ nsSessionStorageEntry::~nsSessionStorageEntry()
nsDOMStorageManager* nsDOMStorageManager::gStorageManager;
nsDOMStorageManager::nsDOMStorageManager()
: mInPrivateBrowsing(false)
{
}
@ -253,6 +252,8 @@ nsDOMStorageManager::Initialize()
NS_ENSURE_SUCCESS(rv, rv);
rv = os->AddObserver(gStorageManager, "offline-app-removed", true);
NS_ENSURE_SUCCESS(rv, rv);
rv = os->AddObserver(gStorageManager, NS_PRIVATE_BROWSING_SWITCH_TOPIC, true);
NS_ENSURE_SUCCESS(rv, rv);
rv = os->AddObserver(gStorageManager, "profile-after-change", true);
NS_ENSURE_SUCCESS(rv, rv);
rv = os->AddObserver(gStorageManager, "perm-changed", true);
@ -264,8 +265,6 @@ nsDOMStorageManager::Initialize()
NS_ENSURE_SUCCESS(rv, rv);
rv = os->AddObserver(gStorageManager, NS_DOMSTORAGE_FLUSH_TIMER_TOPIC, true);
NS_ENSURE_SUCCESS(rv, rv);
rv = os->AddObserver(gStorageManager, "last-pb-context-exited", true);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
@ -362,6 +361,10 @@ nsDOMStorageManager::Observe(nsISupports *aSubject,
const PRUnichar *aData)
{
if (!strcmp(aTopic, "profile-after-change")) {
nsCOMPtr<nsIPrivateBrowsingService> pbs =
do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID);
if (pbs)
pbs->GetPrivateBrowsingEnabled(&gStorageManager->mInPrivateBrowsing);
}
else if (!strcmp(aTopic, "offline-app-removed")) {
nsresult rv = DOMStorageImpl::InitDB();
@ -380,6 +383,16 @@ nsDOMStorageManager::Observe(nsISupports *aSubject,
rv = GetOfflineDomains(domains);
NS_ENSURE_SUCCESS(rv, rv);
return DOMStorageImpl::gStorageDB->RemoveOwners(domains, true, false);
} else if (!strcmp(aTopic, NS_PRIVATE_BROWSING_SWITCH_TOPIC)) {
mStorages.EnumerateEntries(ClearStorage, nsnull);
if (!nsCRT::strcmp(aData, NS_LITERAL_STRING(NS_PRIVATE_BROWSING_ENTER).get()))
mInPrivateBrowsing = true;
else if (!nsCRT::strcmp(aData, NS_LITERAL_STRING(NS_PRIVATE_BROWSING_LEAVE).get()))
mInPrivateBrowsing = false;
nsresult rv = DOMStorageImpl::InitDB();
NS_ENSURE_SUCCESS(rv, rv);
return DOMStorageImpl::gStorageDB->DropPrivateBrowsingStorages();
} else if (!strcmp(aTopic, "perm-changed")) {
// Check for cookie permission change
nsCOMPtr<nsIPermission> perm(do_QueryInterface(aSubject));
@ -458,10 +471,6 @@ nsDOMStorageManager::Observe(nsISupports *aSubject,
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"DOMStorage: temporary table commit failed");
}
} else if (!strcmp(aTopic, "last-pb-context-exited")) {
if (DOMStorageImpl::gStorageDB) {
return DOMStorageImpl::gStorageDB->DropPrivateBrowsingStorages();
}
}
return NS_OK;
@ -475,7 +484,7 @@ nsDOMStorageManager::GetUsage(const nsAString& aDomain,
NS_ENSURE_SUCCESS(rv, rv);
return DOMStorageImpl::gStorageDB->GetUsage(NS_ConvertUTF16toUTF8(aDomain),
false, aUsage, false);
false, aUsage);
}
NS_IMETHODIMP
@ -493,7 +502,6 @@ nsDOMStorageManager::ClearOfflineApps()
NS_IMETHODIMP
nsDOMStorageManager::GetLocalStorageForPrincipal(nsIPrincipal *aPrincipal,
const nsSubstring &aDocumentURI,
bool aPrivate,
nsIDOMStorage **aResult)
{
NS_ENSURE_ARG_POINTER(aPrincipal);
@ -505,7 +513,7 @@ nsDOMStorageManager::GetLocalStorageForPrincipal(nsIPrincipal *aPrincipal,
if (!storage)
return NS_ERROR_OUT_OF_MEMORY;
rv = storage->InitAsLocalStorage(aPrincipal, aDocumentURI, aPrivate);
rv = storage->InitAsLocalStorage(aPrincipal, aDocumentURI);
if (NS_FAILED(rv))
return rv;
@ -562,19 +570,9 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMStorage)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMStorageObsolete)
NS_INTERFACE_MAP_ENTRY(nsIDOMStorageObsolete)
NS_INTERFACE_MAP_ENTRY(nsPIDOMStorage)
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(StorageObsolete)
NS_INTERFACE_MAP_END
NS_IMETHODIMP
nsDOMStorage::GetInterface(const nsIID & aIID, void **result)
{
nsresult rv = mStorageImpl->QueryInterface(aIID, result);
if (NS_SUCCEEDED(rv))
return rv;
return QueryInterface(aIID, result);
}
nsresult
NS_NewDOMStorage2(nsISupports* aOuter, REFNSIID aIID, void** aResult)
{
@ -587,7 +585,6 @@ DOMStorageBase::DOMStorageBase()
, mUseDB(false)
, mSessionOnly(true)
, mCanUseChromePersist(false)
, mInPrivateBrowsing(false)
{
}
@ -600,12 +597,11 @@ DOMStorageBase::DOMStorageBase(DOMStorageBase& aThat)
, mQuotaETLDplus1DomainDBKey(aThat.mQuotaETLDplus1DomainDBKey)
, mQuotaDomainDBKey(aThat.mQuotaDomainDBKey)
, mCanUseChromePersist(aThat.mCanUseChromePersist)
, mInPrivateBrowsing(aThat.mInPrivateBrowsing)
{
}
void
DOMStorageBase::InitAsSessionStorage(nsIURI* aDomainURI, bool aPrivate)
DOMStorageBase::InitAsSessionStorage(nsIURI* aDomainURI)
{
// No need to check for a return value. If this would fail we would not get
// here as we call GetPrincipalURIAndHost (nsDOMStorage.cpp:88) from
@ -618,13 +614,11 @@ DOMStorageBase::InitAsSessionStorage(nsIURI* aDomainURI, bool aPrivate)
mScopeDBKey.Truncate();
mQuotaDomainDBKey.Truncate();
mStorageType = nsPIDOMStorage::SessionStorage;
mInPrivateBrowsing = aPrivate;
}
void
DOMStorageBase::InitAsLocalStorage(nsIURI* aDomainURI,
bool aCanUseChromePersist,
bool aPrivate)
bool aCanUseChromePersist)
{
// No need to check for a return value. If this would fail we would not get
// here as we call GetPrincipalURIAndHost (nsDOMStorage.cpp:88) from
@ -648,7 +642,6 @@ DOMStorageBase::InitAsLocalStorage(nsIURI* aDomainURI,
true, true, mQuotaETLDplus1DomainDBKey);
mCanUseChromePersist = aCanUseChromePersist;
mStorageType = nsPIDOMStorage::LocalStorage;
mInPrivateBrowsing = aPrivate;
}
PLDHashOperator
@ -674,9 +667,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMStorageImpl)
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMStorageImpl)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMStorageImpl)
NS_INTERFACE_MAP_ENTRY(nsIPrivacyTransitionObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIPrivacyTransitionObserver)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
DOMStorageImpl::DOMStorageImpl(nsDOMStorage* aStorage)
@ -732,8 +723,7 @@ DOMStorageImpl::InitDB()
void
DOMStorageImpl::InitFromChild(bool aUseDB, bool aCanUseChromePersist,
bool aSessionOnly, bool aPrivate,
const nsACString& aDomain,
bool aSessionOnly, const nsACString& aDomain,
const nsACString& aScopeDBKey,
const nsACString& aQuotaDomainDBKey,
const nsACString& aQuotaETLDplus1DomainDBKey,
@ -742,7 +732,6 @@ DOMStorageImpl::InitFromChild(bool aUseDB, bool aCanUseChromePersist,
mUseDB = aUseDB;
mCanUseChromePersist = aCanUseChromePersist;
mSessionOnly = aSessionOnly;
mInPrivateBrowsing = aPrivate;
mDomain = aDomain;
mScopeDBKey = aScopeDBKey;
mQuotaDomainDBKey = aQuotaDomainDBKey;
@ -757,17 +746,16 @@ DOMStorageImpl::SetSessionOnly(bool aSessionOnly)
}
void
DOMStorageImpl::InitAsSessionStorage(nsIURI* aDomainURI, bool aPrivate)
DOMStorageImpl::InitAsSessionStorage(nsIURI* aDomainURI)
{
DOMStorageBase::InitAsSessionStorage(aDomainURI, aPrivate);
DOMStorageBase::InitAsSessionStorage(aDomainURI);
}
void
DOMStorageImpl::InitAsLocalStorage(nsIURI* aDomainURI,
bool aCanUseChromePersist,
bool aPrivate)
bool aCanUseChromePersist)
{
DOMStorageBase::InitAsLocalStorage(aDomainURI, aCanUseChromePersist, aPrivate);
DOMStorageBase::InitAsLocalStorage(aDomainURI, aCanUseChromePersist);
}
bool
@ -777,7 +765,7 @@ DOMStorageImpl::CacheStoragePermissions()
// All the correct checks have been done on the child, so we just need to
// make sure that our session-only status is correctly updated.
if (!mOwner)
return CanUseStorage();
return nsDOMStorage::CanUseStorage(&mSessionOnly);
return mOwner->CacheStoragePermissions();
}
@ -1267,16 +1255,6 @@ DOMStorageImpl::Clear(bool aCallerSecure, PRInt32* aOldCount)
return NS_OK;
}
NS_IMETHODIMP
DOMStorageImpl::PrivateModeChanged(bool enabled)
{
mInPrivateBrowsing = enabled;
CanUseStorage(); // cause mSessionOnly to update as well
mItems.Clear();
mItemsCachedVersion = 0;
return NS_OK;
}
nsDOMStorage::nsDOMStorage()
: mStorageType(nsPIDOMStorage::Unknown)
, mEventBroadcaster(nsnull)
@ -1335,8 +1313,7 @@ GetDomainURI(nsIPrincipal *aPrincipal, bool aIncludeDomain, nsIURI **_domain)
}
nsresult
nsDOMStorage::InitAsSessionStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI,
bool aPrivate)
nsDOMStorage::InitAsSessionStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI)
{
nsCOMPtr<nsIURI> domainURI;
nsresult rv = GetDomainURI(aPrincipal, true, getter_AddRefs(domainURI));
@ -1347,13 +1324,12 @@ nsDOMStorage::InitAsSessionStorage(nsIPrincipal *aPrincipal, const nsSubstring &
mStorageType = SessionStorage;
mStorageImpl->InitAsSessionStorage(domainURI, aPrivate);
mStorageImpl->InitAsSessionStorage(domainURI);
return NS_OK;
}
nsresult
nsDOMStorage::InitAsLocalStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI,
bool aPrivate)
nsDOMStorage::InitAsLocalStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI)
{
nsCOMPtr<nsIURI> domainURI;
nsresult rv = GetDomainURI(aPrincipal, false, getter_AddRefs(domainURI));
@ -1370,25 +1346,18 @@ nsDOMStorage::InitAsLocalStorage(nsIPrincipal *aPrincipal, const nsSubstring &aD
canUseChromePersist = URICanUseChromePersist(URI);
}
mStorageImpl->InitAsLocalStorage(domainURI, canUseChromePersist, aPrivate);
mStorageImpl->InitAsLocalStorage(domainURI, canUseChromePersist);
return NS_OK;
}
bool
DOMStorageBase::CanUseStorage()
{
return nsDOMStorage::CanUseStorage(this);
}
//static
bool
nsDOMStorage::CanUseStorage(DOMStorageBase* aStorage /* = NULL */)
nsDOMStorage::CanUseStorage(bool* aSessionOnly)
{
if (aStorage) {
// check if the calling domain can use storage. Downgrade to session
// only if only session storage may be used.
aStorage->mSessionOnly = false;
}
// check if the calling domain can use storage. Downgrade to session
// only if only session storage may be used.
NS_ASSERTION(aSessionOnly, "null session flag");
*aSessionOnly = false;
if (!Preferences::GetBool(kStorageEnabled)) {
return false;
@ -1429,9 +1398,8 @@ nsDOMStorage::CanUseStorage(DOMStorageBase* aStorage /* = NULL */)
// mode to prevent detection of being in private browsing mode and ensuring
// that there will be no traces left.
if (perm == nsICookiePermission::ACCESS_SESSION ||
(aStorage && aStorage->IsPrivate())) {
if (aStorage)
aStorage->mSessionOnly = true;
nsDOMStorageManager::gStorageManager->InPrivateBrowsingMode()) {
*aSessionOnly = true;
}
else if (perm != nsIPermissionManager::ALLOW_ACTION) {
PRUint32 cookieBehavior = Preferences::GetUint(kCookiesBehavior);
@ -1443,8 +1411,8 @@ nsDOMStorage::CanUseStorage(DOMStorageBase* aStorage /* = NULL */)
!URICanUseChromePersist(subjectURI))
return false;
if (lifetimePolicy == ACCEPT_SESSION && aStorage)
aStorage->mSessionOnly = true;
if (lifetimePolicy == ACCEPT_SESSION)
*aSessionOnly = true;
}
return true;
@ -1456,7 +1424,7 @@ nsDOMStorage::CacheStoragePermissions()
// Bug 488446, disallowing storage use when in session only mode.
// This is temporary fix before we find complete solution for storage
// behavior in private browsing mode or session-only cookies mode.
if (!mStorageImpl->CanUseStorage())
if (!CanUseStorage(&mStorageImpl->mSessionOnly))
return false;
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
@ -1733,19 +1701,9 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMStorage2)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMStorage)
NS_INTERFACE_MAP_ENTRY(nsIDOMStorage)
NS_INTERFACE_MAP_ENTRY(nsPIDOMStorage)
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Storage)
NS_INTERFACE_MAP_END
NS_IMETHODIMP
nsDOMStorage2::GetInterface(const nsIID & aIID, void **result)
{
nsresult rv = mStorage->GetInterface(aIID, result);
if (NS_SUCCEEDED(rv))
return rv;
return QueryInterface(aIID, result);;
}
nsDOMStorage2::nsDOMStorage2()
{
}
@ -1757,8 +1715,7 @@ nsDOMStorage2::nsDOMStorage2(nsDOMStorage2& aThat)
}
nsresult
nsDOMStorage2::InitAsSessionStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI,
bool aPrivate)
nsDOMStorage2::InitAsSessionStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI)
{
mStorage = new nsDOMStorage();
if (!mStorage)
@ -1767,12 +1724,11 @@ nsDOMStorage2::InitAsSessionStorage(nsIPrincipal *aPrincipal, const nsSubstring
mPrincipal = aPrincipal;
mDocumentURI = aDocumentURI;
return mStorage->InitAsSessionStorage(aPrincipal, aDocumentURI, aPrivate);
return mStorage->InitAsSessionStorage(aPrincipal, aDocumentURI);
}
nsresult
nsDOMStorage2::InitAsLocalStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI,
bool aPrivate)
nsDOMStorage2::InitAsLocalStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI)
{
mStorage = new nsDOMStorage();
if (!mStorage)
@ -1781,7 +1737,7 @@ nsDOMStorage2::InitAsLocalStorage(nsIPrincipal *aPrincipal, const nsSubstring &a
mPrincipal = aPrincipal;
mDocumentURI = aDocumentURI;
return mStorage->InitAsLocalStorage(aPrincipal, aDocumentURI, aPrivate);
return mStorage->InitAsLocalStorage(aPrincipal, aDocumentURI);
}
already_AddRefed<nsIDOMStorage>
@ -1951,7 +1907,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMStorageItem)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMStorageItem)
{
cb.NoteXPCOMChild(tmp->mStorage);
cb.NoteXPCOMChild((nsISupports*) tmp->mStorage);
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

Просмотреть файл

@ -12,7 +12,6 @@
#include "nsIDOMStorage.h"
#include "nsIDOMStorageItem.h"
#include "nsIPermissionManager.h"
#include "nsIPrivacyTransitionObserver.h"
#include "nsInterfaceHashtable.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
@ -25,7 +24,6 @@
#include "nsIObserver.h"
#include "nsITimer.h"
#include "nsWeakReference.h"
#include "nsIInterfaceRequestor.h"
#include "nsDOMStorageDBWrapper.h"
@ -89,6 +87,8 @@ public:
nsresult ClearAllStorages();
bool InPrivateBrowsingMode() { return mInPrivateBrowsing; }
static nsresult Initialize();
static nsDOMStorageManager* GetInstance();
static void Shutdown();
@ -104,16 +104,17 @@ public:
protected:
nsTHashtable<nsDOMStorageEntry> mStorages;
bool mInPrivateBrowsing;
};
class DOMStorageBase : public nsIPrivacyTransitionObserver
class DOMStorageBase : public nsISupports
{
public:
DOMStorageBase();
DOMStorageBase(DOMStorageBase&);
virtual void InitAsSessionStorage(nsIURI* aDomainURI, bool aPrivate);
virtual void InitAsLocalStorage(nsIURI* aDomainURI, bool aCanUseChromePersist, bool aPrivate);
virtual void InitAsSessionStorage(nsIURI* aDomainURI);
virtual void InitAsLocalStorage(nsIURI* aDomainURI, bool aCanUseChromePersist);
virtual nsTArray<nsString>* GetKeys(bool aCallerSecure) = 0;
virtual nsresult GetLength(bool aCallerSecure, PRUint32* aLength) = 0;
@ -125,10 +126,7 @@ public:
virtual nsresult RemoveValue(bool aCallerSecure, const nsAString& aKey,
nsAString& aOldValue) = 0;
virtual nsresult Clear(bool aCallerSecure, PRInt32* aOldCount) = 0;
// Call nsDOMStorage::CanUseStorage with |this|
bool CanUseStorage();
// If true, the contents of the storage should be stored in the
// database, otherwise this storage should act like a session
// storage.
@ -139,10 +137,6 @@ public:
return mUseDB;
}
bool IsPrivate() {
return mInPrivateBrowsing;
}
// retrieve the value and secure state corresponding to a key out of storage.
virtual nsresult
GetDBValue(const nsAString& aKey,
@ -204,23 +198,21 @@ protected:
nsCString mQuotaDomainDBKey;
bool mCanUseChromePersist;
bool mInPrivateBrowsing;
};
class DOMStorageImpl : public DOMStorageBase
, public nsSupportsWeakReference
{
public:
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(DOMStorageImpl, nsIPrivacyTransitionObserver)
NS_DECL_CYCLE_COLLECTION_CLASS(DOMStorageImpl)
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIPRIVACYTRANSITIONOBSERVER
DOMStorageImpl(nsDOMStorage*);
DOMStorageImpl(nsDOMStorage*, DOMStorageImpl&);
~DOMStorageImpl();
virtual void InitAsSessionStorage(nsIURI* aDomainURI, bool aPrivate);
virtual void InitAsLocalStorage(nsIURI* aDomainURI, bool aCanUseChromePersist, bool aPrivate);
virtual void InitAsSessionStorage(nsIURI* aDomainURI);
virtual void InitAsLocalStorage(nsIURI* aDomainURI, bool aCanUseChromePersist);
bool SessionOnly() {
return mSessionOnly;
@ -291,7 +283,7 @@ private:
// Cross-process storage implementations never have InitAs(Session|Local|Global)Storage
// called, so the appropriate initialization needs to happen from the child.
void InitFromChild(bool aUseDB, bool aCanUseChromePersist, bool aSessionOnly,
bool aPrivate, const nsACString& aDomain,
const nsACString& aDomain,
const nsACString& aScopeDBKey,
const nsACString& aQuotaDomainDBKey,
const nsACString& aQuotaETLDplus1DomainDBKey,
@ -314,8 +306,7 @@ private:
class nsDOMStorage2;
class nsDOMStorage : public nsIDOMStorageObsolete,
public nsPIDOMStorage,
public nsIInterfaceRequestor
public nsPIDOMStorage
{
public:
nsDOMStorage();
@ -326,17 +317,14 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsDOMStorage, nsIDOMStorageObsolete)
NS_DECL_NSIDOMSTORAGEOBSOLETE
NS_DECL_NSIINTERFACEREQUESTOR
// Helpers for implementing nsIDOMStorage
nsresult GetItem(const nsAString& key, nsAString& aData);
nsresult Clear();
// nsPIDOMStorage
virtual nsresult InitAsSessionStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI,
bool aPrivate);
virtual nsresult InitAsLocalStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI,
bool aPrivate);
virtual nsresult InitAsSessionStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI);
virtual nsresult InitAsLocalStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI);
virtual already_AddRefed<nsIDOMStorage> Clone();
virtual already_AddRefed<nsIDOMStorage> Fork(const nsSubstring &aDocumentURI);
virtual bool IsForkOf(nsIDOMStorage* aThat);
@ -348,7 +336,7 @@ public:
// Check whether storage may be used by the caller, and whether it
// is session only. Returns true if storage may be used.
static bool
CanUseStorage(DOMStorageBase* aStorage = nsnull);
CanUseStorage(bool* aSessionOnly);
// Check whether this URI can use chrome persist storage. This kind of
// storage can bypass cookies limits, private browsing and uses the offline
@ -393,8 +381,7 @@ public:
};
class nsDOMStorage2 : public nsIDOMStorage,
public nsPIDOMStorage,
public nsIInterfaceRequestor
public nsPIDOMStorage
{
public:
// nsISupports
@ -405,13 +392,10 @@ public:
nsDOMStorage2();
NS_DECL_NSIDOMSTORAGE
NS_DECL_NSIINTERFACEREQUESTOR
// nsPIDOMStorage
virtual nsresult InitAsSessionStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI,
bool aPrivate);
virtual nsresult InitAsLocalStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI,
bool aPrivate);
virtual nsresult InitAsSessionStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI);
virtual nsresult InitAsLocalStorage(nsIPrincipal *aPrincipal, const nsSubstring &aDocumentURI);
virtual already_AddRefed<nsIDOMStorage> Clone();
virtual already_AddRefed<nsIDOMStorage> Fork(const nsSubstring &aDocumentURI);
virtual bool IsForkOf(nsIDOMStorage* aThat);

Просмотреть файл

@ -90,7 +90,7 @@ nsDOMStorageDBWrapper::FlushAndDeleteTemporaryTables(bool force)
PR_BEGIN_MACRO \
if (aStorage->CanUseChromePersist()) \
_return mChromePersistentDB._code; \
if (aStorage->IsPrivate()) \
if (nsDOMStorageManager::gStorageManager->InPrivateBrowsingMode()) \
_return mPrivateBrowsingDB._code; \
if (aStorage->SessionOnly()) \
_return mSessionOnlyDB._code; \
@ -188,6 +188,9 @@ nsDOMStorageDBWrapper::RemoveOwner(const nsACString& aOwner,
rv = mPrivateBrowsingDB.RemoveOwner(aOwner, aIncludeSubDomains);
NS_ENSURE_SUCCESS(rv, rv);
if (nsDOMStorageManager::gStorageManager->InPrivateBrowsingMode())
return NS_OK;
rv = mSessionOnlyDB.RemoveOwner(aOwner, aIncludeSubDomains);
NS_ENSURE_SUCCESS(rv, rv);
@ -207,6 +210,9 @@ nsDOMStorageDBWrapper::RemoveOwners(const nsTArray<nsString> &aOwners,
rv = mPrivateBrowsingDB.RemoveOwners(aOwners, aIncludeSubDomains, aMatch);
NS_ENSURE_SUCCESS(rv, rv);
if (nsDOMStorageManager::gStorageManager->InPrivateBrowsingMode())
return NS_OK;
rv = mSessionOnlyDB.RemoveOwners(aOwners, aIncludeSubDomains, aMatch);
NS_ENSURE_SUCCESS(rv, rv);
@ -216,6 +222,26 @@ nsDOMStorageDBWrapper::RemoveOwners(const nsTArray<nsString> &aOwners,
return rv;
}
nsresult
nsDOMStorageDBWrapper::RemoveAll()
{
nsresult rv;
rv = mPrivateBrowsingDB.RemoveAll();
NS_ENSURE_SUCCESS(rv, rv);
if (nsDOMStorageManager::gStorageManager->InPrivateBrowsingMode())
return NS_OK;
rv = mSessionOnlyDB.RemoveAll();
NS_ENSURE_SUCCESS(rv, rv);
rv = mPersistentDB.RemoveAll();
NS_ENSURE_SUCCESS(rv, rv);
return rv;
}
nsresult
nsDOMStorageDBWrapper::GetUsage(DOMStorageImpl* aStorage,
bool aExcludeOfflineFromUsage, PRInt32 *aUsage)
@ -225,9 +251,9 @@ nsDOMStorageDBWrapper::GetUsage(DOMStorageImpl* aStorage,
nsresult
nsDOMStorageDBWrapper::GetUsage(const nsACString& aDomain,
bool aIncludeSubDomains, PRInt32 *aUsage, bool aPrivate)
bool aIncludeSubDomains, PRInt32 *aUsage)
{
if (aPrivate)
if (nsDOMStorageManager::gStorageManager->InPrivateBrowsingMode())
return mPrivateBrowsingDB.GetUsage(aDomain, aIncludeSubDomains, aUsage);
#if 0

Просмотреть файл

@ -144,6 +144,12 @@ public:
RemoveOwners(const nsTArray<nsString>& aOwners,
bool aIncludeSubDomains, bool aMatch);
/**
* Removes all keys from storage. Used when clearing storage.
*/
nsresult
RemoveAll();
/**
* Returns usage for a storage using its GetQuotaDomainDBKey() as a key.
*/
@ -154,7 +160,7 @@ public:
* Returns usage of the domain and optionaly by any subdomain.
*/
nsresult
GetUsage(const nsACString& aDomain, bool aIncludeSubDomains, PRInt32 *aUsage, bool aPrivate);
GetUsage(const nsACString& aDomain, bool aIncludeSubDomains, PRInt32 *aUsage);
/**
* Marks the storage as "cached" after the DOMStorageImpl object has loaded