mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
e4e2da55c9
The bulk of this commit was generated with a script, executed at the top level of a typical source code checkout. The only non-machine-generated part was modifying MFBT's moz.build to reflect the new naming. CLOSED TREE makes big refactorings like this a piece of cake. # The main substitution. find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \ xargs perl -p -i -e ' s/nsRefPtr\.h/RefPtr\.h/g; # handle includes s/nsRefPtr ?</RefPtr</g; # handle declarations and variables ' # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h. perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h # Handle nsRefPtr.h itself, a couple places that define constructors # from nsRefPtr, and code generators specially. We do this here, rather # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename # things like nsRefPtrHashtable. perl -p -i -e 's/nsRefPtr/RefPtr/g' \ mfbt/nsRefPtr.h \ xpcom/glue/nsCOMPtr.h \ xpcom/base/OwningNonNull.h \ ipc/ipdl/ipdl/lower.py \ ipc/ipdl/ipdl/builtin.py \ dom/bindings/Codegen.py \ python/lldbutils/lldbutils/utils.py # In our indiscriminate substitution above, we renamed # nsRefPtrGetterAddRefs, the class behind getter_AddRefs. Fix that up. find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \ xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g' if [ -d .git ]; then git mv mfbt/nsRefPtr.h mfbt/RefPtr.h else hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h fi
145 lines
4.8 KiB
C++
145 lines
4.8 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* 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/. */
|
|
|
|
#ifndef nsDOMStorageManager_h__
|
|
#define nsDOMStorageManager_h__
|
|
|
|
#include "nsIDOMStorageManager.h"
|
|
#include "DOMStorageObserver.h"
|
|
|
|
#include "DOMStorageCache.h"
|
|
#include "mozilla/dom/DOMStorage.h"
|
|
|
|
#include "nsTHashtable.h"
|
|
#include "nsDataHashtable.h"
|
|
#include "nsHashKeys.h"
|
|
|
|
class nsIDOMWindow;
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
const DOMStorage::StorageType SessionStorage = DOMStorage::SessionStorage;
|
|
const DOMStorage::StorageType LocalStorage = DOMStorage::LocalStorage;
|
|
|
|
class DOMStorageManager : public nsIDOMStorageManager
|
|
, public DOMStorageObserverSink
|
|
{
|
|
NS_DECL_ISUPPORTS
|
|
NS_DECL_NSIDOMSTORAGEMANAGER
|
|
|
|
public:
|
|
virtual DOMStorage::StorageType Type() { return mType; }
|
|
|
|
// Reads the preference for DOM storage quota
|
|
static uint32_t GetQuota();
|
|
// Gets (but not ensures) cache for the given scope
|
|
DOMStorageCache* GetCache(const nsACString& aScope) const;
|
|
// Returns object keeping usage cache for the scope.
|
|
already_AddRefed<DOMStorageUsage> GetScopeUsage(const nsACString& aScope);
|
|
|
|
protected:
|
|
explicit DOMStorageManager(DOMStorage::StorageType aType);
|
|
virtual ~DOMStorageManager();
|
|
|
|
private:
|
|
// DOMStorageObserverSink, handler to various chrome clearing notification
|
|
virtual nsresult Observe(const char* aTopic, const nsACString& aScopePrefix) override;
|
|
|
|
// Since nsTHashtable doesn't like multiple inheritance, we have to aggregate
|
|
// DOMStorageCache into the entry.
|
|
class DOMStorageCacheHashKey : public nsCStringHashKey
|
|
{
|
|
public:
|
|
explicit DOMStorageCacheHashKey(const nsACString* aKey)
|
|
: nsCStringHashKey(aKey)
|
|
, mCache(new DOMStorageCache(aKey))
|
|
{}
|
|
|
|
DOMStorageCacheHashKey(const DOMStorageCacheHashKey& aOther)
|
|
: nsCStringHashKey(aOther)
|
|
{
|
|
NS_ERROR("Shouldn't be called");
|
|
}
|
|
|
|
DOMStorageCache* cache() { return mCache; }
|
|
// Keep the cache referenced forever, used for sessionStorage.
|
|
void HardRef() { mCacheRef = mCache; }
|
|
|
|
private:
|
|
// weak ref only since cache references its manager.
|
|
DOMStorageCache* mCache;
|
|
// hard ref when this is sessionStorage to keep it alive forever.
|
|
RefPtr<DOMStorageCache> mCacheRef;
|
|
};
|
|
|
|
// Ensures cache for a scope, when it doesn't exist it is created and initalized,
|
|
// this also starts preload of persistent data.
|
|
already_AddRefed<DOMStorageCache> PutCache(const nsACString& aScope,
|
|
nsIPrincipal* aPrincipal);
|
|
|
|
// Helper for creation of DOM storage objects
|
|
nsresult GetStorageInternal(bool aCreate,
|
|
nsIDOMWindow* aWindow,
|
|
nsIPrincipal* aPrincipal,
|
|
const nsAString& aDocumentURI,
|
|
bool aPrivate,
|
|
nsIDOMStorage** aRetval);
|
|
|
|
// Scope->cache map
|
|
nsTHashtable<DOMStorageCacheHashKey> mCaches;
|
|
const DOMStorage::StorageType mType;
|
|
|
|
// If mLowDiskSpace is true it indicates a low device storage situation and
|
|
// so no localStorage writes are allowed. sessionStorage writes are still
|
|
// allowed.
|
|
bool mLowDiskSpace;
|
|
bool IsLowDiskSpace() const { return mLowDiskSpace; };
|
|
|
|
void ClearCaches(uint32_t aUnloadFlags, const nsACString& aKeyPrefix);
|
|
|
|
protected:
|
|
// Keeps usage cache objects for eTLD+1 scopes we have touched.
|
|
nsDataHashtable<nsCStringHashKey, RefPtr<DOMStorageUsage> > mUsages;
|
|
|
|
friend class DOMStorageCache;
|
|
// Releases cache since it is no longer referrered by any DOMStorage object.
|
|
virtual void DropCache(DOMStorageCache* aCache);
|
|
};
|
|
|
|
// Derived classes to allow two different contract ids, one for localStorage and
|
|
// one for sessionStorage management. localStorage manager is used as service
|
|
// scoped to the application while sessionStorage managers are instantiated by each
|
|
// top doc shell in the application since sessionStorages are isolated per top level
|
|
// browsing context. The code may easily by shared by both.
|
|
|
|
class DOMLocalStorageManager final : public DOMStorageManager
|
|
{
|
|
public:
|
|
DOMLocalStorageManager();
|
|
virtual ~DOMLocalStorageManager();
|
|
|
|
// Global getter of localStorage manager service
|
|
static DOMLocalStorageManager* Self() { return sSelf; }
|
|
|
|
// Like Self, but creates an instance if we're not yet initialized.
|
|
static DOMLocalStorageManager* Ensure();
|
|
|
|
private:
|
|
static DOMLocalStorageManager* sSelf;
|
|
};
|
|
|
|
class DOMSessionStorageManager final : public DOMStorageManager
|
|
{
|
|
public:
|
|
DOMSessionStorageManager();
|
|
};
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|
|
|
|
#endif /* nsDOMStorageManager_h__ */
|