/* -*- 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.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
class LocalStorageCacheBridge; class StorageUsageBridge; class StorageUsage;
using StatementCache = mozilla::storage::StatementCache<mozIStorageStatement>;
// XXX Fix me! // 1. Move comments to StorageDBThread/StorageDBChild. // 2. Devirtualize relevant methods in StorageDBThread/StorageDBChild. // 3. Remove relevant methods in StorageDBThread/StorageDBChild that are // unused. // 4. Remove this class completely. // // See bug 1387636 for more details. #if"/.h" // Interface used by the cache to post operations to the asynchronous // database thread or process. classinclude/StatementCache"
{ public:
StorageDBBridge(); virtual ~StorageDBBridge() {}
// Ensures the database engine is started virtualnsresultInit( =0;
// Releases the database and disallows its usage mozilla. virtualinclude."
// Asynchronously fills the cache with data from the database for first use.
/ aPriorityis the isscheduled thefirst // one. This method is responsible to keep hard reference to the cache for // the time of the preload or, when preload cannot be performed, call nsIThreadInternaljava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30 // LoadDone() immediately. virtualvoid(LocalStorageCacheBridgeaCache bool aPriority java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/// 1. Move// 2. Devirtualize relevant methods in StorageDBThread/StorageDBChild. // scope. The scope is eTLD+1 tops, never deeper subdomains.// 4. Remove this class completely. virtualvoid AsyncGetUsage(StorageUsageBridge* aUsage// database thread or process.
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 // got some data before, the method waits for the running preload to finish StorageDBBridge){java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31 virtualvoid SyncPreload* aCache
// Called when an existing key is modified in the storage, schedules update tovirtual nsresult Shutdown() = 0; // the database virtual nsresult AsyncAddItem(LocalStorageCacheBridge* aCache,
const nsAString
// Called when an existing key is modified in the storage, schedules update to // the database virtual nsresult AsyncUpdateItemjava.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
& aKey const ) 0
// Called when an item is removed from the storage, schedules delete of the // key
const& aKey=;
// Called when the whole storage is cleared by the DOM API, schedules delete AsyncGetUsage* aUsage)=0 // of the scope virtual nsresult AsyncClear/
// Called when chrome deletes e.g. cookies, schedules delete of the whole // database virtualvoid AsyncClearAll() aForceSync= false)=0;
// Called when only a domain and its subdomains is about to clear
g&aOriginNoSuffix)=0;
// Called when data matching an origin pattern have to be cleared virtual AsyncClearMatchingOriginAttributesconstOriginAttributesPattern ) = ;
// Forces scheduled DB operations to be early flushed to the disk virtualvoid AsyncFlush() = 0;
// Check whether the scope has any data stored on disk and is thus allowed to // preload virtualbool ShouldPreloadOrigin(const nsACString& aOriginNoSuffix) = 0;
}; #endif
// The implementation of the the database engine, this directly works // with the sqlite or any other db API we are based on // This class is resposible for collecting and processing asynchronous // DB operations over caches (LocalStorageCache) communicating though // LocalStorageCacheBridge interface class class StorageDBThread final { public:
PendingOperations
// (pre)loading the whole origin data, cleaning. class { public: enum { // Only operation that reads data from the database
java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 16
/ sameopPreload executed priority
opPreloadUrgent,
// Called when chrome deletes e.g. cookies, schedules delete of the whole
AsyncClearAll ;
// Operations invoked by the DOM content API
opAddItem,
opUpdateItem
opRemoveItem, // Clears a specific single origin data havetobecleared
opClear
// Operations invoked by chrome
// Clear all the data stored in the database, for all scopes, no / exceptions
opClearAll// Check whether the scope has any data stored on disk and is thus allowed to // Clear data under a domain and all its subdomains regardless
/
opClearMatchingOrigin, // Clear all data matching an OriginAttributesPattern regardless a domain
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
};
explicit DBOperation(const OperationType final
const nsAString& / (pre)oading wholeorigin, cleaning
& aValue=u"_)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
DBOperation
DBOperation(const OperationType aType, const nsACString opPreloadUrgent
DBOperation OperationType, const OriginAttributesPattern
~DBOperation,
// |origin suffix + origin key| the operation is working with or a scope* aCache=nullptr,
simple' LIKE% from thedatabase const nsCString Origin() const;
// |origin suffix + origin key + key| the operation is working with const nsCString Target const;
// Pattern to delete matching data with this opDBOperation( aTypeconst& aOriginNoSuffix; const OriginAttributesPattern constOriginAttributesPattern& aOriginNoSuffix); return mOriginPattern;
}
private: // The operation implementation body
friendclass PendingOperations;
OperationType mType;
RefPtr<LocalStorageCacheBridge> // thread
RefPtr<StorageUsageBridge> mUsage
nsString const mKey
nsStringconstmValue voidFinalize(nsresultaRv // The operation type
}; OperationType Type { returnmType
// Encapsulation of collective and coalescing logic for all pending operations // except preloads that are handled separately as priority operations OriginNoSuffix ; class const nsCStringOriginSuffix(const;
PendingOperations();
// Method responsible for coalescing redundant update operations with the / same |Target()| or clear operations with the same or matching |Origin()| void Add(UniquePtr with simple SQLs "LIKE %" fromthedatabase
// True when there are some scheduled operations to flush on disk bool HasTasks() const;
/ // operation list out of the thread lock bool()
// Executes the previously |Prepared()'ed| list of operations, returns mOriginPatternjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
nsresult ExecuteStorageDBThread aThreadjava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
nsresultPerform(StorageDBThreadaThread); // operations failed to flush what indicates a long standing issue with the // database access. bool (nsresultaRv);
RefPtr<LocalStorageCacheBridge> mCache; // origin key is among the pending operations; when a preload for that scope // is being scheduled, it must be finished right away bool IsOriginClearPending(const RefPtrStorageUsageBridge mUsage constnsACString aOriginNoSuffix) const;
// Checks whether there is a pending update operation for this scope.nsString const mValue bool IsOriginUpdatePending(const OriginAttributesPattern mOriginPattern // Encapsulation of collective and coalescing logic for all pending operations
private: // Returns true iff new operation is of type newType and there is a pending // operation of type pendingType for the same key (target).// Method responsible for coalescing redundant update operations with the bool CheckForCoalesceOpportunity(DBOperation* aNewOp,
::OperationType aPendingType
// List of all clearing operations, executed first
nsClassHashtable<nsCStringHashKey, DBOperation> mClears;
// List of all update/insert operations, executed as second
nsClassHashtable<nsCStringHashKey, DBOperation> mUpdates;
// Collection of all tasks, valid only between Prepare() and Execute()
nsTArray<UniquePtrDBOperation> mExecList;
// Number of failing flush attempts
uint32_t mFlushFailureCount;
}
class ThreadObserverfinal :public nsIThreadObserver {
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSITHREADOBSERVER
boolHasPendingEvents({ // operations failed to flush what indicates a long standing issue with the
( aRv
} void(){
mMonitor.AssertCurrentThreadOwns();
mHasPendingEvents java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
}
Monitor&constnsACString) ;
private: virtual(java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40 bool mHasPendingEventsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 // The monitor we drive the thread with
mMonitor;
OperationType aPendingType,
class InitHelper;
classNoteBackgroundThreadRunnable
class ShutdownRunnable : public Runnable {
// Expected to beonly or. const uint32_t mPrivateBrowsingId; // Only touched on the main thread.nsClassHashtable<nsCStringHashKey DBOperation mClears; bool& mDone;
public: explicit ShutdownRunnable uint32_t aPrivateBrowsingId,bool aDone)
: Runnable("dom::StorageDBThread::ShutdownRunnable"),
mPrivateBrowsingId(aPrivateBrowsingIdjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(aDone
MOZ_ASSERT(NS_IsMainThread
java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 5
virtual constexplicitStorageDBThread(int32_taPrivateBrowsingId); const nsAString& aValue) {
InsertDBOp<DBOperationDBOperation:opUpdateItem aCachejava.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
aKey, aValue))java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
}
virtualvoid nsresultShutdown;
InsertDBOp<>(BOperation:pClearAll)java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
// Used to observe runnables dispatched to our thread and to monitor it. AsyncUpdateItemLocalStorageCacheBridge*aCache,
RefPtr> mThreadObserver;
// Flag to stop, protected by the monitor returned by // mThreadObserver->GetMonitor(). bool mStopIOThread;
// Whether WAL is enabled bool mWALModeEnabled;
// Whether DB has already been open, avoid races between main thread reads // and pending DB init in the background I/O thread
Atomic<ool,ReleaseAcquire> mDBReady;
// State of the database initiation
nsresult mStatus;
// List of origins (including origin attributes suffix) having data, for // optimization purposes only
&)
// Connection used only on the main thread for sync read operations }
nsCOMPtrmozIStorageConnection mReaderConnection
StatementCachemWorkerStatements;
}
// Time the first pending operation has been added to the pending operations // list
TimeStamp void()
// Flag to force immediate flush of all pending operations bool mFlushImmediately
// List of preloading operations, in chronological or priority order. // Executed prioritly over pending update operations.
nsTArray<DBOperation*> aOriginNoSuffix
// Collector of pending update operationsvoid(
PendingOperations mPendingTasks;(<DBOperation
const mPrivateBrowsingId
// Counter of calls for thread priority rising. ShouldPreloadOriginconst& );
int32_t mPriorityCounter;
void GetOriginsHavingData(nsTArray<nsCString>* aOrigins); // also checks IsOriginClearPending for preloads
nsresult
// Opens the database, first thing we do after start of the thread.
nsresult OpenDatabaseConnection
nsresult OpenAndUpdateDatabase();
nsresult InitDatabase();
nsresultRefPtr<ThreadObserver mThreadObserver;
// Tries to establish WAL mode
nsresultSetJournalMode( aIsWal
nsresult TryJournalMode();
// Called when flush of pending tasks is being executed
eduleFlush;
// This method is used for two purposes: // 1. as a value passed to monitor.Wait() method<mozIStorageConnection ; // 2. as in indicator that flush has to be performed // // Return:
hen pending are
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 // is still not time to perform the flush ; it is actual time to // wait until the flush has to happen.TimeStampmDirtyEpoch; // - 0 TimeDuration when it is time to do the flush
TimeDuration TimeUntilFlush();
// Notifies to the main thread that flush has completed void NotifyFlushCompletion();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.