2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2011-10-27 13:11:34 +04:00
|
|
|
|
|
|
|
#ifndef mozilla_places_Database_h_
|
|
|
|
#define mozilla_places_Database_h_
|
|
|
|
|
2013-09-19 17:54:42 +04:00
|
|
|
#include "MainThreadUtils.h"
|
2011-10-27 13:11:34 +04:00
|
|
|
#include "nsWeakReference.h"
|
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
|
|
|
#include "nsIObserver.h"
|
2015-05-05 13:44:16 +03:00
|
|
|
#include "nsIAsyncShutdown.h"
|
2011-10-27 13:11:34 +04:00
|
|
|
#include "mozilla/storage.h"
|
|
|
|
#include "mozilla/storage/StatementCache.h"
|
2012-06-20 07:58:39 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-09-19 17:54:42 +04:00
|
|
|
#include "nsIEventTarget.h"
|
2016-02-04 15:51:34 +03:00
|
|
|
#include "Shutdown.h"
|
2017-06-09 19:51:09 +03:00
|
|
|
#include "nsCategoryCache.h"
|
2011-10-27 13:11:34 +04:00
|
|
|
|
2011-12-02 01:58:19 +04:00
|
|
|
// This is the schema version. Update it at any schema change and add a
|
2011-10-27 13:11:34 +04:00
|
|
|
// corresponding migrateVxx method below.
|
2018-03-26 17:44:41 +03:00
|
|
|
#define DATABASE_SCHEMA_VERSION 46
|
2011-10-27 13:11:34 +04:00
|
|
|
|
|
|
|
// Fired after Places inited.
|
|
|
|
#define TOPIC_PLACES_INIT_COMPLETE "places-init-complete"
|
|
|
|
// This topic is received when the profile is about to be lost. Places does
|
|
|
|
// initial shutdown work and notifies TOPIC_PLACES_SHUTDOWN to all listeners.
|
|
|
|
// Any shutdown work that requires the Places APIs should happen here.
|
|
|
|
#define TOPIC_PROFILE_CHANGE_TEARDOWN "profile-change-teardown"
|
|
|
|
// Fired when Places is shutting down. Any code should stop accessing Places
|
|
|
|
// APIs after this notification. If you need to listen for Places shutdown
|
|
|
|
// you should only use this notification, next ones are intended only for
|
|
|
|
// internal Places use.
|
|
|
|
#define TOPIC_PLACES_SHUTDOWN "places-shutdown"
|
|
|
|
// Fired when the connection has gone, nothing will work from now on.
|
|
|
|
#define TOPIC_PLACES_CONNECTION_CLOSED "places-connection-closed"
|
|
|
|
|
2015-05-05 13:44:16 +03:00
|
|
|
// Simulate profile-before-change. This topic may only be used by
|
|
|
|
// calling `observe` directly on the database. Used for testing only.
|
2016-02-04 15:51:34 +03:00
|
|
|
#define TOPIC_SIMULATE_PLACES_SHUTDOWN "test-simulate-places-shutdown"
|
2015-05-05 13:44:16 +03:00
|
|
|
|
2013-09-19 17:54:42 +04:00
|
|
|
class nsIRunnable;
|
2011-12-13 21:52:06 +04:00
|
|
|
|
2011-10-27 13:11:34 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace places {
|
|
|
|
|
|
|
|
enum JournalMode {
|
|
|
|
// Default SQLite journal mode.
|
|
|
|
JOURNAL_DELETE = 0
|
|
|
|
// Can reduce fsyncs on Linux when journal is deleted (See bug 460315).
|
|
|
|
// We fallback to this mode when WAL is unavailable.
|
|
|
|
, JOURNAL_TRUNCATE
|
|
|
|
// Unsafe in case of crashes on database swap or low memory.
|
|
|
|
, JOURNAL_MEMORY
|
|
|
|
// Can reduce number of fsyncs. We try to use this mode by default.
|
|
|
|
, JOURNAL_WAL
|
|
|
|
};
|
|
|
|
|
2016-02-04 15:51:34 +03:00
|
|
|
class ClientsShutdownBlocker;
|
|
|
|
class ConnectionShutdownBlocker;
|
2015-05-05 13:44:16 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class Database final : public nsIObserver
|
2015-03-27 21:52:19 +03:00
|
|
|
, public nsSupportsWeakReference
|
2011-10-27 13:11:34 +04:00
|
|
|
{
|
|
|
|
typedef mozilla::storage::StatementCache<mozIStorageStatement> StatementCache;
|
|
|
|
typedef mozilla::storage::StatementCache<mozIStorageAsyncStatement> AsyncStatementCache;
|
|
|
|
|
|
|
|
public:
|
2013-07-19 06:24:15 +04:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2011-10-27 13:11:34 +04:00
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
|
|
|
Database();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes the database connection and the schema.
|
|
|
|
* In case of corruption the database is copied to a backup file and replaced.
|
|
|
|
*/
|
|
|
|
nsresult Init();
|
|
|
|
|
|
|
|
/**
|
2015-05-05 13:44:16 +03:00
|
|
|
* The AsyncShutdown client used by clients of this API to be informed of shutdown.
|
2011-10-27 13:11:34 +04:00
|
|
|
*/
|
2016-02-04 15:51:34 +03:00
|
|
|
already_AddRefed<nsIAsyncShutdownClient> GetClientsShutdown();
|
2011-10-27 13:11:34 +04:00
|
|
|
|
2016-05-20 00:50:27 +03:00
|
|
|
/**
|
|
|
|
* The AsyncShutdown client used by clients of this API to be informed of connection shutdown.
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsIAsyncShutdownClient> GetConnectionShutdown();
|
|
|
|
|
2011-10-27 13:11:34 +04:00
|
|
|
/**
|
|
|
|
* Getter to use when instantiating the class.
|
|
|
|
*
|
|
|
|
* @return Singleton instance of this class.
|
|
|
|
*/
|
2015-07-25 12:07:24 +03:00
|
|
|
static already_AddRefed<Database> GetDatabase();
|
2011-10-27 13:11:34 +04:00
|
|
|
|
2017-06-09 19:51:09 +03:00
|
|
|
/**
|
|
|
|
* Actually initialized the connection on first need.
|
|
|
|
*/
|
|
|
|
nsresult EnsureConnection();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notifies that the connection has been initialized.
|
|
|
|
*/
|
|
|
|
nsresult NotifyConnectionInitalized();
|
|
|
|
|
2011-10-27 13:11:34 +04:00
|
|
|
/**
|
|
|
|
* Returns last known database status.
|
|
|
|
*
|
|
|
|
* @return one of the nsINavHistoryService::DATABASE_STATUS_* constants.
|
|
|
|
*/
|
2017-06-09 19:51:09 +03:00
|
|
|
uint16_t GetDatabaseStatus()
|
2011-10-27 13:11:34 +04:00
|
|
|
{
|
2017-06-09 19:51:09 +03:00
|
|
|
mozilla::Unused << EnsureConnection();
|
2011-10-27 13:11:34 +04:00
|
|
|
return mDatabaseStatus;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a pointer to the storage connection.
|
|
|
|
*
|
|
|
|
* @return The connection handle.
|
|
|
|
*/
|
2017-06-09 19:51:09 +03:00
|
|
|
mozIStorageConnection* MainConn()
|
2011-10-27 13:11:34 +04:00
|
|
|
{
|
2017-06-09 19:51:09 +03:00
|
|
|
mozilla::Unused << EnsureConnection();
|
2011-10-27 13:11:34 +04:00
|
|
|
return mMainConn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatches a runnable to the connection async thread, to be serialized
|
|
|
|
* with async statements.
|
|
|
|
*
|
|
|
|
* @param aEvent
|
|
|
|
* The runnable to be dispatched.
|
|
|
|
*/
|
2017-06-09 19:51:09 +03:00
|
|
|
void DispatchToAsyncThread(nsIRunnable* aEvent)
|
2011-10-27 13:11:34 +04:00
|
|
|
{
|
2017-06-09 19:51:09 +03:00
|
|
|
if (mClosed || NS_FAILED(EnsureConnection())) {
|
2011-10-27 13:11:34 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIEventTarget> target = do_GetInterface(mMainConn);
|
|
|
|
if (target) {
|
|
|
|
(void)target->Dispatch(aEvent, NS_DISPATCH_NORMAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// Statements Getters.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a cached synchronous statement.
|
|
|
|
*
|
|
|
|
* @param aQuery
|
|
|
|
* SQL query literal.
|
|
|
|
* @return The cached statement.
|
|
|
|
* @note Always null check the result.
|
|
|
|
* @note Always use a scoper to reset the statement.
|
|
|
|
*/
|
|
|
|
template<int N>
|
|
|
|
already_AddRefed<mozIStorageStatement>
|
2017-06-09 19:51:09 +03:00
|
|
|
GetStatement(const char (&aQuery)[N])
|
2011-10-27 13:11:34 +04:00
|
|
|
{
|
|
|
|
nsDependentCString query(aQuery, N - 1);
|
|
|
|
return GetStatement(query);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a cached synchronous statement.
|
|
|
|
*
|
|
|
|
* @param aQuery
|
|
|
|
* nsCString of SQL query.
|
|
|
|
* @return The cached statement.
|
|
|
|
* @note Always null check the result.
|
|
|
|
* @note Always use a scoper to reset the statement.
|
|
|
|
*/
|
2017-06-09 19:51:09 +03:00
|
|
|
already_AddRefed<mozIStorageStatement> GetStatement(const nsACString& aQuery);
|
2011-10-27 13:11:34 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a cached asynchronous statement.
|
|
|
|
*
|
|
|
|
* @param aQuery
|
|
|
|
* SQL query literal.
|
|
|
|
* @return The cached statement.
|
|
|
|
* @note Always null check the result.
|
|
|
|
* @note AsyncStatements are automatically reset on execution.
|
|
|
|
*/
|
|
|
|
template<int N>
|
|
|
|
already_AddRefed<mozIStorageAsyncStatement>
|
2017-06-09 19:51:09 +03:00
|
|
|
GetAsyncStatement(const char (&aQuery)[N])
|
2011-10-27 13:11:34 +04:00
|
|
|
{
|
|
|
|
nsDependentCString query(aQuery, N - 1);
|
|
|
|
return GetAsyncStatement(query);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a cached asynchronous statement.
|
|
|
|
*
|
|
|
|
* @param aQuery
|
|
|
|
* nsCString of SQL query.
|
|
|
|
* @return The cached statement.
|
|
|
|
* @note Always null check the result.
|
|
|
|
* @note AsyncStatements are automatically reset on execution.
|
|
|
|
*/
|
2017-06-09 19:51:09 +03:00
|
|
|
already_AddRefed<mozIStorageAsyncStatement> GetAsyncStatement(const nsACString& aQuery);
|
2011-10-27 13:11:34 +04:00
|
|
|
|
2016-04-22 12:47:31 +03:00
|
|
|
uint32_t MaxUrlLength();
|
|
|
|
|
2011-10-27 13:11:34 +04:00
|
|
|
protected:
|
2015-05-05 13:44:16 +03:00
|
|
|
/**
|
|
|
|
* Finalizes the cached statements and closes the database connection.
|
|
|
|
* A TOPIC_PLACES_CONNECTION_CLOSED notification is fired when done.
|
|
|
|
*/
|
2017-06-09 19:51:09 +03:00
|
|
|
void Shutdown();
|
2015-05-05 13:44:16 +03:00
|
|
|
|
|
|
|
bool IsShutdownStarted() const;
|
|
|
|
|
2011-10-27 13:11:34 +04:00
|
|
|
/**
|
|
|
|
* Initializes the database file. If the database does not exist or is
|
|
|
|
* corrupt, a new one is created. In case of corruption it also creates a
|
|
|
|
* backup copy of the database.
|
|
|
|
*
|
|
|
|
* @param aStorage
|
|
|
|
* mozStorage service instance.
|
|
|
|
* @param aNewDatabaseCreated
|
|
|
|
* whether a new database file has been created.
|
|
|
|
*/
|
|
|
|
nsresult InitDatabaseFile(nsCOMPtr<mozIStorageService>& aStorage,
|
|
|
|
bool* aNewDatabaseCreated);
|
|
|
|
|
Bug 977177 - Move favicons to a separate store. r=adw
This patch moves favicons blobs to a separate database names favicons.sqlite.
The dabatase is then ATTACHED to the main Places connection, so that its tables
can be used as if they were all part of the same database.
The favicons.database contains 3 tables:
1. moz_pages_w_icons
This is the way to join with moz_places, through page_url_hash and page_url.
We are not using the place id to avoid possible mismatches between places.sqlite
and favicons.sqlite. This way the database is "portable" and reusable even
if places.sqlite changes.
2. moz_icons
Contains icons payloads, each payload can either be an SVG or a PNG. These
are the only stored formats, any other format is rescaled and converted to
PNG. ICO files are split into single frames and stored as multiple PNGs.
SVG are distinguishable through width == UINT16_MAX
In future the table will also contain mask-icon color for SVG and average
color for PNGs.
The fixed_icon_url_hash is "fixed" to allow quickly fetch root icons, that
means icons like "domain/favicon.ico" that can also be reused for any page
under that domain.
3. moz_icons_to_pages
This is the relation table between icons and pages.
Each page can have multiple icons, each icon can be used by multiple pages.
There is a FOREIGN_KEY constraint between this (child) table and icons
or pages (parents), so that it's not possible to insert non-existing ids
in this table, and if an entry is removed from a parent table, the relation
will be automatically removed from here.
Note though that removing from the relation table won't remove from the
parent tables.
Since the relations are now many-many, it's no more possible to simply join
places with the icons table and obtain a single icon, thus it's suggested that
consumers go through the "page-icon" protocol.
The migration process from the old favicons table is async and interruptible,
it will be restarted along with the favicons service until the temp preference
places.favicons.convertPayloads is set to true.
MozReview-Commit-ID: CUCoL9smRyt
--HG--
extra : rebase_source : 4d25966596dcdf63c9c872425c5bf147406d25ac
2016-11-14 18:22:46 +03:00
|
|
|
/**
|
2017-05-24 16:19:39 +03:00
|
|
|
* Ensure the favicons database file exists.
|
Bug 977177 - Move favicons to a separate store. r=adw
This patch moves favicons blobs to a separate database names favicons.sqlite.
The dabatase is then ATTACHED to the main Places connection, so that its tables
can be used as if they were all part of the same database.
The favicons.database contains 3 tables:
1. moz_pages_w_icons
This is the way to join with moz_places, through page_url_hash and page_url.
We are not using the place id to avoid possible mismatches between places.sqlite
and favicons.sqlite. This way the database is "portable" and reusable even
if places.sqlite changes.
2. moz_icons
Contains icons payloads, each payload can either be an SVG or a PNG. These
are the only stored formats, any other format is rescaled and converted to
PNG. ICO files are split into single frames and stored as multiple PNGs.
SVG are distinguishable through width == UINT16_MAX
In future the table will also contain mask-icon color for SVG and average
color for PNGs.
The fixed_icon_url_hash is "fixed" to allow quickly fetch root icons, that
means icons like "domain/favicon.ico" that can also be reused for any page
under that domain.
3. moz_icons_to_pages
This is the relation table between icons and pages.
Each page can have multiple icons, each icon can be used by multiple pages.
There is a FOREIGN_KEY constraint between this (child) table and icons
or pages (parents), so that it's not possible to insert non-existing ids
in this table, and if an entry is removed from a parent table, the relation
will be automatically removed from here.
Note though that removing from the relation table won't remove from the
parent tables.
Since the relations are now many-many, it's no more possible to simply join
places with the icons table and obtain a single icon, thus it's suggested that
consumers go through the "page-icon" protocol.
The migration process from the old favicons table is async and interruptible,
it will be restarted along with the favicons service until the temp preference
places.favicons.convertPayloads is set to true.
MozReview-Commit-ID: CUCoL9smRyt
--HG--
extra : rebase_source : 4d25966596dcdf63c9c872425c5bf147406d25ac
2016-11-14 18:22:46 +03:00
|
|
|
*
|
|
|
|
* @param aStorage
|
|
|
|
* mozStorage service instance.
|
|
|
|
*/
|
2017-05-24 16:19:39 +03:00
|
|
|
nsresult EnsureFaviconsDatabaseFile(nsCOMPtr<mozIStorageService>& aStorage);
|
Bug 977177 - Move favicons to a separate store. r=adw
This patch moves favicons blobs to a separate database names favicons.sqlite.
The dabatase is then ATTACHED to the main Places connection, so that its tables
can be used as if they were all part of the same database.
The favicons.database contains 3 tables:
1. moz_pages_w_icons
This is the way to join with moz_places, through page_url_hash and page_url.
We are not using the place id to avoid possible mismatches between places.sqlite
and favicons.sqlite. This way the database is "portable" and reusable even
if places.sqlite changes.
2. moz_icons
Contains icons payloads, each payload can either be an SVG or a PNG. These
are the only stored formats, any other format is rescaled and converted to
PNG. ICO files are split into single frames and stored as multiple PNGs.
SVG are distinguishable through width == UINT16_MAX
In future the table will also contain mask-icon color for SVG and average
color for PNGs.
The fixed_icon_url_hash is "fixed" to allow quickly fetch root icons, that
means icons like "domain/favicon.ico" that can also be reused for any page
under that domain.
3. moz_icons_to_pages
This is the relation table between icons and pages.
Each page can have multiple icons, each icon can be used by multiple pages.
There is a FOREIGN_KEY constraint between this (child) table and icons
or pages (parents), so that it's not possible to insert non-existing ids
in this table, and if an entry is removed from a parent table, the relation
will be automatically removed from here.
Note though that removing from the relation table won't remove from the
parent tables.
Since the relations are now many-many, it's no more possible to simply join
places with the icons table and obtain a single icon, thus it's suggested that
consumers go through the "page-icon" protocol.
The migration process from the old favicons table is async and interruptible,
it will be restarted along with the favicons service until the temp preference
places.favicons.convertPayloads is set to true.
MozReview-Commit-ID: CUCoL9smRyt
--HG--
extra : rebase_source : 4d25966596dcdf63c9c872425c5bf147406d25ac
2016-11-14 18:22:46 +03:00
|
|
|
|
2011-10-27 13:11:34 +04:00
|
|
|
/**
|
|
|
|
* Creates a database backup and replaces the original file with a new
|
|
|
|
* one.
|
|
|
|
*
|
|
|
|
* @param aStorage
|
|
|
|
* mozStorage service instance.
|
2017-12-07 16:05:29 +03:00
|
|
|
* @param aTryToClone
|
|
|
|
* whether we should try to clone a corrupt database.
|
2011-10-27 13:11:34 +04:00
|
|
|
*/
|
2017-12-07 16:05:29 +03:00
|
|
|
nsresult BackupAndReplaceDatabaseFile(nsCOMPtr<mozIStorageService>& aStorage,
|
|
|
|
bool aTryToClone);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tries to recover tables and their contents from a corrupt database.
|
|
|
|
*
|
|
|
|
* @param aStorage
|
|
|
|
* mozStorage service instance.
|
|
|
|
*/
|
|
|
|
nsresult TryToCloneTablesFromCorruptDatabase(nsCOMPtr<mozIStorageService>& aStorage);
|
2011-10-27 13:11:34 +04:00
|
|
|
|
|
|
|
/**
|
2017-05-24 16:19:39 +03:00
|
|
|
* Set up the connection environment through PRAGMAs.
|
|
|
|
* Will return NS_ERROR_FILE_CORRUPTED if any critical setting fails.
|
|
|
|
*
|
|
|
|
* @param aStorage
|
|
|
|
* mozStorage service instance.
|
|
|
|
*/
|
|
|
|
nsresult SetupDatabaseConnection(nsCOMPtr<mozIStorageService>& aStorage);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes the schema. This performs any necessary migrations for the
|
2011-10-27 13:11:34 +04:00
|
|
|
* database. All migration is done inside a transaction that is rolled back
|
|
|
|
* if any error occurs.
|
|
|
|
* @param aDatabaseMigrated
|
|
|
|
* Whether a schema upgrade happened.
|
|
|
|
*/
|
|
|
|
nsresult InitSchema(bool* aDatabaseMigrated);
|
|
|
|
|
2011-12-13 21:52:06 +04:00
|
|
|
/**
|
|
|
|
* Creates bookmark roots in a new DB.
|
|
|
|
*/
|
|
|
|
nsresult CreateBookmarkRoots();
|
|
|
|
|
2011-10-27 13:11:34 +04:00
|
|
|
/**
|
|
|
|
* Initializes additionale SQLite functions, defined in SQLFunctions.h
|
|
|
|
*/
|
|
|
|
nsresult InitFunctions();
|
|
|
|
|
|
|
|
/**
|
2016-02-23 04:21:03 +03:00
|
|
|
* Initializes temp entities, like triggers, tables, views...
|
2015-05-27 15:52:34 +03:00
|
|
|
*/
|
2016-02-23 04:21:03 +03:00
|
|
|
nsresult InitTempEntities();
|
2011-10-27 13:11:34 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Helpers used by schema upgrades.
|
|
|
|
*/
|
2016-03-16 13:56:25 +03:00
|
|
|
nsresult MigrateV31Up();
|
2016-04-22 12:47:31 +03:00
|
|
|
nsresult MigrateV32Up();
|
2016-06-29 15:47:36 +03:00
|
|
|
nsresult MigrateV33Up();
|
2016-08-30 12:04:22 +03:00
|
|
|
nsresult MigrateV34Up();
|
2016-09-29 23:44:08 +03:00
|
|
|
nsresult MigrateV35Up();
|
2016-11-20 19:22:02 +03:00
|
|
|
nsresult MigrateV36Up();
|
Bug 977177 - Move favicons to a separate store. r=adw
This patch moves favicons blobs to a separate database names favicons.sqlite.
The dabatase is then ATTACHED to the main Places connection, so that its tables
can be used as if they were all part of the same database.
The favicons.database contains 3 tables:
1. moz_pages_w_icons
This is the way to join with moz_places, through page_url_hash and page_url.
We are not using the place id to avoid possible mismatches between places.sqlite
and favicons.sqlite. This way the database is "portable" and reusable even
if places.sqlite changes.
2. moz_icons
Contains icons payloads, each payload can either be an SVG or a PNG. These
are the only stored formats, any other format is rescaled and converted to
PNG. ICO files are split into single frames and stored as multiple PNGs.
SVG are distinguishable through width == UINT16_MAX
In future the table will also contain mask-icon color for SVG and average
color for PNGs.
The fixed_icon_url_hash is "fixed" to allow quickly fetch root icons, that
means icons like "domain/favicon.ico" that can also be reused for any page
under that domain.
3. moz_icons_to_pages
This is the relation table between icons and pages.
Each page can have multiple icons, each icon can be used by multiple pages.
There is a FOREIGN_KEY constraint between this (child) table and icons
or pages (parents), so that it's not possible to insert non-existing ids
in this table, and if an entry is removed from a parent table, the relation
will be automatically removed from here.
Note though that removing from the relation table won't remove from the
parent tables.
Since the relations are now many-many, it's no more possible to simply join
places with the icons table and obtain a single icon, thus it's suggested that
consumers go through the "page-icon" protocol.
The migration process from the old favicons table is async and interruptible,
it will be restarted along with the favicons service until the temp preference
places.favicons.convertPayloads is set to true.
MozReview-Commit-ID: CUCoL9smRyt
--HG--
extra : rebase_source : 4d25966596dcdf63c9c872425c5bf147406d25ac
2016-11-14 18:22:46 +03:00
|
|
|
nsresult MigrateV37Up();
|
2017-05-23 21:54:13 +03:00
|
|
|
nsresult MigrateV38Up();
|
2017-09-02 23:15:04 +03:00
|
|
|
nsresult MigrateV39Up();
|
2017-09-18 11:31:20 +03:00
|
|
|
nsresult MigrateV40Up();
|
2017-10-20 13:48:37 +03:00
|
|
|
nsresult MigrateV41Up();
|
2018-01-18 17:06:39 +03:00
|
|
|
nsresult MigrateV42Up();
|
2018-02-06 17:58:31 +03:00
|
|
|
nsresult MigrateV43Up();
|
2018-03-02 14:09:12 +03:00
|
|
|
nsresult MigrateV44Up();
|
2018-03-03 22:19:22 +03:00
|
|
|
nsresult MigrateV45Up();
|
2018-03-26 17:44:41 +03:00
|
|
|
nsresult MigrateV46Up();
|
2011-12-02 01:58:19 +04:00
|
|
|
|
2011-12-13 21:52:06 +04:00
|
|
|
nsresult UpdateBookmarkRootTitles();
|
2011-10-27 13:11:34 +04:00
|
|
|
|
2016-02-04 15:51:34 +03:00
|
|
|
friend class ConnectionShutdownBlocker;
|
2015-05-05 13:44:16 +03:00
|
|
|
|
2016-09-29 23:44:08 +03:00
|
|
|
int64_t CreateMobileRoot();
|
|
|
|
nsresult GetItemsWithAnno(const nsACString& aAnnoName, int32_t aItemType,
|
|
|
|
nsTArray<int64_t>& aItemIds);
|
|
|
|
nsresult DeleteBookmarkItem(int32_t aItemId);
|
|
|
|
|
2011-10-27 13:11:34 +04:00
|
|
|
private:
|
|
|
|
~Database();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Singleton getter, invoked by class instantiation.
|
|
|
|
*/
|
2013-04-28 15:52:10 +04:00
|
|
|
static already_AddRefed<Database> GetSingleton();
|
2011-10-27 13:11:34 +04:00
|
|
|
|
|
|
|
static Database* gDatabase;
|
|
|
|
|
|
|
|
nsCOMPtr<mozIStorageConnection> mMainConn;
|
|
|
|
|
|
|
|
mutable StatementCache mMainThreadStatements;
|
|
|
|
mutable AsyncStatementCache mMainThreadAsyncStatements;
|
|
|
|
mutable StatementCache mAsyncThreadStatements;
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mDBPageSize;
|
|
|
|
uint16_t mDatabaseStatus;
|
2013-07-19 17:51:40 +04:00
|
|
|
bool mClosed;
|
2017-10-20 18:14:17 +03:00
|
|
|
// Used to track whether icon payloads should be converted at the end of
|
|
|
|
// schema migration.
|
|
|
|
bool mShouldConvertIconPayloads;
|
2018-01-18 17:06:39 +03:00
|
|
|
// Used to track whether the favicons database should be vacuumed at the end
|
|
|
|
// of the schema migration.
|
|
|
|
bool mShouldVacuumIcons;
|
2015-05-05 13:44:16 +03:00
|
|
|
|
|
|
|
/**
|
2016-02-04 15:51:34 +03:00
|
|
|
* Phases for shutting down the Database.
|
|
|
|
* See Shutdown.h for further details about the shutdown procedure.
|
2015-05-05 13:44:16 +03:00
|
|
|
*/
|
2016-02-04 15:51:34 +03:00
|
|
|
already_AddRefed<nsIAsyncShutdownClient> GetProfileChangeTeardownPhase();
|
|
|
|
already_AddRefed<nsIAsyncShutdownClient> GetProfileBeforeChangePhase();
|
2015-05-05 13:44:16 +03:00
|
|
|
|
|
|
|
/**
|
2016-02-04 15:51:34 +03:00
|
|
|
* Blockers in charge of waiting for the Places clients and then shutting
|
|
|
|
* down the mozStorage connection.
|
|
|
|
* See Shutdown.h for further details about the shutdown procedure.
|
2015-05-05 13:44:16 +03:00
|
|
|
*
|
2016-02-04 15:51:34 +03:00
|
|
|
* Cycles with these are broken in `Shutdown()`.
|
2015-05-05 13:44:16 +03:00
|
|
|
*/
|
2016-02-04 15:51:34 +03:00
|
|
|
RefPtr<ClientsShutdownBlocker> mClientsShutdown;
|
|
|
|
RefPtr<ConnectionShutdownBlocker> mConnectionShutdown;
|
2016-04-22 12:47:31 +03:00
|
|
|
|
|
|
|
// Maximum length of a stored url.
|
|
|
|
// For performance reasons we don't store very long urls in history, since
|
|
|
|
// they are slower to search through and cause abnormal database growth,
|
|
|
|
// affecting the awesomebar fetch time.
|
|
|
|
uint32_t mMaxUrlLength;
|
2017-06-09 19:51:09 +03:00
|
|
|
|
|
|
|
// Used to initialize components on places startup.
|
|
|
|
nsCategoryCache<nsIObserver> mCacheObservers;
|
2011-10-27 13:11:34 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace places
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_places_Database_h_
|