2010-10-19 13:46:49 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
|
2012-05-21 11:12:37 +00: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/. */
|
2010-10-19 13:46:49 +00:00
|
|
|
|
2012-12-14 23:58:45 +00:00
|
|
|
#include "mozilla/DebugOnly.h"
|
|
|
|
|
2010-10-19 13:46:49 +00:00
|
|
|
#include "VacuumManager.h"
|
|
|
|
|
|
|
|
#include "mozilla/Services.h"
|
2011-06-02 01:05:12 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
2010-10-19 13:46:49 +00:00
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsIFile.h"
|
|
|
|
#include "nsThreadUtils.h"
|
2015-05-19 18:15:34 +00:00
|
|
|
#include "mozilla/Logging.h"
|
2013-09-23 17:29:27 +00:00
|
|
|
#include "prtime.h"
|
2010-10-19 13:46:49 +00:00
|
|
|
|
|
|
|
#include "mozStorageConnection.h"
|
|
|
|
#include "mozIStorageStatement.h"
|
|
|
|
#include "mozIStorageAsyncStatement.h"
|
|
|
|
#include "mozIStoragePendingStatement.h"
|
|
|
|
#include "mozIStorageError.h"
|
2012-01-05 23:46:35 +00:00
|
|
|
#include "mozStorageHelper.h"
|
2013-08-29 16:10:35 +00:00
|
|
|
#include "nsXULAppAPI.h"
|
2010-10-19 13:46:49 +00:00
|
|
|
|
|
|
|
#define OBSERVER_TOPIC_IDLE_DAILY "idle-daily"
|
|
|
|
#define OBSERVER_TOPIC_XPCOM_SHUTDOWN "xpcom-shutdown"
|
|
|
|
|
|
|
|
// Used to notify begin and end of a heavy IO task.
|
|
|
|
#define OBSERVER_TOPIC_HEAVY_IO "heavy-io-task"
|
|
|
|
#define OBSERVER_DATA_VACUUM_BEGIN NS_LITERAL_STRING("vacuum-begin")
|
|
|
|
#define OBSERVER_DATA_VACUUM_END NS_LITERAL_STRING("vacuum-end")
|
|
|
|
|
|
|
|
// This preferences root will contain last vacuum timestamps (in seconds) for
|
|
|
|
// each database. The database filename is used as a key.
|
|
|
|
#define PREF_VACUUM_BRANCH "storage.vacuum.last."
|
|
|
|
|
|
|
|
// Time between subsequent vacuum calls for a certain database.
|
|
|
|
#define VACUUM_INTERVAL_SECONDS 30 * 86400 // 30 days.
|
|
|
|
|
|
|
|
extern PRLogModuleInfo *gStorageLog;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace storage {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// BaseCallback
|
|
|
|
|
|
|
|
class BaseCallback : public mozIStorageStatementCallback
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_MOZISTORAGESTATEMENTCALLBACK
|
|
|
|
BaseCallback() {}
|
|
|
|
protected:
|
|
|
|
virtual ~BaseCallback() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
BaseCallback::HandleError(mozIStorageError *aError)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t result;
|
2010-10-19 13:46:49 +00:00
|
|
|
nsresult rv = aError->GetResult(&result);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString message;
|
2010-10-19 13:46:49 +00:00
|
|
|
rv = aError->GetMessage(message);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString warnMsg;
|
2010-10-19 13:46:49 +00:00
|
|
|
warnMsg.AppendLiteral("An error occured during async execution: ");
|
|
|
|
warnMsg.AppendInt(result);
|
2014-05-22 03:48:51 +00:00
|
|
|
warnMsg.Append(' ');
|
2010-10-19 13:46:49 +00:00
|
|
|
warnMsg.Append(message);
|
|
|
|
NS_WARNING(warnMsg.get());
|
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
BaseCallback::HandleResult(mozIStorageResultSet *aResultSet)
|
|
|
|
{
|
|
|
|
// We could get results from PRAGMA statements, but we don't mind them.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
BaseCallback::HandleCompletion(uint16_t aReason)
|
2010-10-19 13:46:49 +00:00
|
|
|
{
|
|
|
|
// By default BaseCallback will just be silent on completion.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(
|
2010-10-19 13:46:49 +00:00
|
|
|
BaseCallback
|
|
|
|
, mozIStorageStatementCallback
|
|
|
|
)
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// Vacuumer declaration.
|
|
|
|
|
|
|
|
class Vacuumer : public BaseCallback
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_MOZISTORAGESTATEMENTCALLBACK
|
|
|
|
|
2014-08-07 23:47:28 +00:00
|
|
|
explicit Vacuumer(mozIStorageVacuumParticipant *aParticipant);
|
2010-10-19 13:46:49 +00:00
|
|
|
|
|
|
|
bool execute();
|
|
|
|
nsresult notifyCompletion(bool aSucceeded);
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<mozIStorageVacuumParticipant> mParticipant;
|
|
|
|
nsCString mDBFilename;
|
|
|
|
nsCOMPtr<mozIStorageConnection> mDBConn;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// Vacuumer implementation.
|
|
|
|
|
2011-06-02 01:05:12 +00:00
|
|
|
Vacuumer::Vacuumer(mozIStorageVacuumParticipant *aParticipant)
|
2010-10-19 13:46:49 +00:00
|
|
|
: mParticipant(aParticipant)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Vacuumer::execute()
|
|
|
|
{
|
2012-02-22 11:23:05 +00:00
|
|
|
MOZ_ASSERT(NS_IsMainThread(), "Must be running on the main thread!");
|
2010-10-19 13:46:49 +00:00
|
|
|
|
|
|
|
// Get the connection and check its validity.
|
|
|
|
nsresult rv = mParticipant->GetDatabaseConnection(getter_AddRefs(mDBConn));
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2012-02-22 11:23:05 +00:00
|
|
|
bool ready = false;
|
2010-10-19 13:46:49 +00:00
|
|
|
if (!mDBConn || NS_FAILED(mDBConn->GetConnectionReady(&ready)) || !ready) {
|
2012-02-22 11:23:05 +00:00
|
|
|
NS_WARNING("Unable to get a connection to vacuum database");
|
2010-10-19 13:46:49 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-02-22 11:23:05 +00:00
|
|
|
// Ask for the expected page size. Vacuum can change the page size, unless
|
|
|
|
// the database is using WAL journaling.
|
|
|
|
// TODO Bug 634374: figure out a strategy to fix page size with WAL.
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t expectedPageSize = 0;
|
2010-10-19 13:46:49 +00:00
|
|
|
rv = mParticipant->GetExpectedDatabasePageSize(&expectedPageSize);
|
2013-04-05 00:14:46 +00:00
|
|
|
if (NS_FAILED(rv) || !Service::pageSizeIsValid(expectedPageSize)) {
|
2010-10-19 13:46:49 +00:00
|
|
|
NS_WARNING("Invalid page size requested for database, will use default ");
|
|
|
|
NS_WARNING(mDBFilename.get());
|
2013-04-05 00:14:46 +00:00
|
|
|
expectedPageSize = Service::getDefaultPageSize();
|
2010-10-19 13:46:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get the database filename. Last vacuum time is stored under this name
|
|
|
|
// in PREF_VACUUM_BRANCH.
|
|
|
|
nsCOMPtr<nsIFile> databaseFile;
|
|
|
|
mDBConn->GetDatabaseFile(getter_AddRefs(databaseFile));
|
|
|
|
if (!databaseFile) {
|
|
|
|
NS_WARNING("Trying to vacuum a in-memory database!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsAutoString databaseFilename;
|
|
|
|
rv = databaseFile->GetLeafName(databaseFilename);
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
|
|
|
mDBFilename = NS_ConvertUTF16toUTF8(databaseFilename);
|
2012-02-22 11:23:05 +00:00
|
|
|
MOZ_ASSERT(!mDBFilename.IsEmpty(), "Database filename cannot be empty");
|
2010-10-19 13:46:49 +00:00
|
|
|
|
|
|
|
// Check interval from last vacuum.
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t now = static_cast<int32_t>(PR_Now() / PR_USEC_PER_SEC);
|
|
|
|
int32_t lastVacuum;
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString prefName(PREF_VACUUM_BRANCH);
|
2011-06-02 01:05:12 +00:00
|
|
|
prefName += mDBFilename;
|
|
|
|
rv = Preferences::GetInt(prefName.get(), &lastVacuum);
|
2012-02-22 11:23:05 +00:00
|
|
|
if (NS_SUCCEEDED(rv) && (now - lastVacuum) < VACUUM_INTERVAL_SECONDS) {
|
|
|
|
// This database was vacuumed recently, skip it.
|
2010-10-19 13:46:49 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Notify that we are about to start vacuuming. The participant can opt-out
|
|
|
|
// if it cannot handle a vacuum at this time, and then we'll move to the next
|
|
|
|
// one.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool vacuumGranted = false;
|
2010-10-19 13:46:49 +00:00
|
|
|
rv = mParticipant->OnBeginVacuum(&vacuumGranted);
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
|
|
|
if (!vacuumGranted) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Notify a heavy IO task is about to start.
|
|
|
|
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
|
|
|
if (os) {
|
2012-02-22 11:23:05 +00:00
|
|
|
DebugOnly<nsresult> rv =
|
2012-07-30 14:20:58 +00:00
|
|
|
os->NotifyObservers(nullptr, OBSERVER_TOPIC_HEAVY_IO,
|
2012-02-22 11:23:05 +00:00
|
|
|
OBSERVER_DATA_VACUUM_BEGIN.get());
|
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv), "Should be able to notify");
|
2010-10-19 13:46:49 +00:00
|
|
|
}
|
|
|
|
|
2012-02-22 11:23:05 +00:00
|
|
|
// Execute the statements separately, since the pragma may conflict with the
|
|
|
|
// vacuum, if they are executed in the same transaction.
|
|
|
|
nsCOMPtr<mozIStorageAsyncStatement> pageSizeStmt;
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString pageSizeQuery(MOZ_STORAGE_UNIQUIFY_QUERY_STR
|
2012-04-09 13:56:41 +00:00
|
|
|
"PRAGMA page_size = ");
|
|
|
|
pageSizeQuery.AppendInt(expectedPageSize);
|
|
|
|
rv = mDBConn->CreateAsyncStatement(pageSizeQuery,
|
|
|
|
getter_AddRefs(pageSizeStmt));
|
2012-02-22 11:23:05 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<BaseCallback> callback = new BaseCallback();
|
2012-02-22 11:23:05 +00:00
|
|
|
nsCOMPtr<mozIStoragePendingStatement> ps;
|
|
|
|
rv = pageSizeStmt->ExecuteAsync(callback, getter_AddRefs(ps));
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2010-10-19 13:46:49 +00:00
|
|
|
|
|
|
|
nsCOMPtr<mozIStorageAsyncStatement> stmt;
|
|
|
|
rv = mDBConn->CreateAsyncStatement(NS_LITERAL_CSTRING(
|
|
|
|
"VACUUM"
|
|
|
|
), getter_AddRefs(stmt));
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
|
|
|
rv = stmt->ExecuteAsync(this, getter_AddRefs(ps));
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// mozIStorageStatementCallback
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
Vacuumer::HandleError(mozIStorageError *aError)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t result;
|
2010-10-19 13:46:49 +00:00
|
|
|
nsresult rv = aError->GetResult(&result);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString message;
|
2010-10-19 13:46:49 +00:00
|
|
|
rv = aError->GetMessage(message);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString warnMsg;
|
2010-10-19 13:46:49 +00:00
|
|
|
warnMsg.AppendLiteral("Unable to vacuum database: ");
|
|
|
|
warnMsg.Append(mDBFilename);
|
|
|
|
warnMsg.AppendLiteral(" - ");
|
|
|
|
warnMsg.AppendInt(result);
|
2014-05-22 03:48:51 +00:00
|
|
|
warnMsg.Append(' ');
|
2010-10-19 13:46:49 +00:00
|
|
|
warnMsg.Append(message);
|
|
|
|
NS_WARNING(warnMsg.get());
|
|
|
|
#endif
|
|
|
|
|
2015-06-03 22:25:57 +00:00
|
|
|
if (MOZ_LOG_TEST(gStorageLog, LogLevel::Error)) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t result;
|
2010-10-19 13:46:49 +00:00
|
|
|
nsresult rv = aError->GetResult(&result);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString message;
|
2010-10-19 13:46:49 +00:00
|
|
|
rv = aError->GetMessage(message);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2015-06-03 22:25:57 +00:00
|
|
|
MOZ_LOG(gStorageLog, LogLevel::Error,
|
2010-10-19 13:46:49 +00:00
|
|
|
("Vacuum failed with error: %d '%s'. Database was: '%s'",
|
|
|
|
result, message.get(), mDBFilename.get()));
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
Vacuumer::HandleResult(mozIStorageResultSet *aResultSet)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("Got a resultset from a vacuum?");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
Vacuumer::HandleCompletion(uint16_t aReason)
|
2010-10-19 13:46:49 +00:00
|
|
|
{
|
|
|
|
if (aReason == REASON_FINISHED) {
|
|
|
|
// Update last vacuum time.
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t now = static_cast<int32_t>(PR_Now() / PR_USEC_PER_SEC);
|
2012-02-22 11:23:05 +00:00
|
|
|
MOZ_ASSERT(!mDBFilename.IsEmpty(), "Database filename cannot be empty");
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString prefName(PREF_VACUUM_BRANCH);
|
2011-06-02 01:05:12 +00:00
|
|
|
prefName += mDBFilename;
|
2012-02-22 11:23:05 +00:00
|
|
|
DebugOnly<nsresult> rv = Preferences::SetInt(prefName.get(), now);
|
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv), "Should be able to set a preference");
|
2010-10-19 13:46:49 +00:00
|
|
|
}
|
|
|
|
|
2011-02-16 12:51:26 +00:00
|
|
|
notifyCompletion(aReason == REASON_FINISHED);
|
2010-10-19 13:46:49 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
Vacuumer::notifyCompletion(bool aSucceeded)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
|
|
|
if (os) {
|
2012-07-30 14:20:58 +00:00
|
|
|
os->NotifyObservers(nullptr, OBSERVER_TOPIC_HEAVY_IO,
|
2010-10-19 13:46:49 +00:00
|
|
|
OBSERVER_DATA_VACUUM_END.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = mParticipant->OnEndVacuum(aSucceeded);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace
|
2010-10-19 13:46:49 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// VacuumManager
|
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(
|
2010-10-19 13:46:49 +00:00
|
|
|
VacuumManager
|
|
|
|
, nsIObserver
|
|
|
|
)
|
|
|
|
|
|
|
|
VacuumManager *
|
2012-07-30 14:20:58 +00:00
|
|
|
VacuumManager::gVacuumManager = nullptr;
|
2010-10-19 13:46:49 +00:00
|
|
|
|
|
|
|
VacuumManager *
|
|
|
|
VacuumManager::getSingleton()
|
|
|
|
{
|
2013-08-29 16:10:35 +00:00
|
|
|
//Don't allocate it in the child Process.
|
2015-07-04 01:29:00 +00:00
|
|
|
if (!XRE_IsParentProcess()) {
|
2013-08-29 16:10:35 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2010-10-19 13:46:49 +00:00
|
|
|
if (gVacuumManager) {
|
|
|
|
NS_ADDREF(gVacuumManager);
|
|
|
|
return gVacuumManager;
|
|
|
|
}
|
|
|
|
gVacuumManager = new VacuumManager();
|
|
|
|
if (gVacuumManager) {
|
|
|
|
NS_ADDREF(gVacuumManager);
|
|
|
|
}
|
|
|
|
return gVacuumManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
VacuumManager::VacuumManager()
|
|
|
|
: mParticipants("vacuum-participant")
|
|
|
|
{
|
2012-02-22 11:23:05 +00:00
|
|
|
MOZ_ASSERT(!gVacuumManager,
|
|
|
|
"Attempting to create two instances of the service!");
|
2010-10-19 13:46:49 +00:00
|
|
|
gVacuumManager = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
VacuumManager::~VacuumManager()
|
|
|
|
{
|
|
|
|
// Remove the static reference to the service. Check to make sure its us
|
|
|
|
// in case somebody creates an extra instance of the service.
|
2012-02-22 11:23:05 +00:00
|
|
|
MOZ_ASSERT(gVacuumManager == this,
|
|
|
|
"Deleting a non-singleton instance of the service");
|
2010-10-19 13:46:49 +00:00
|
|
|
if (gVacuumManager == this) {
|
2012-07-30 14:20:58 +00:00
|
|
|
gVacuumManager = nullptr;
|
2010-10-19 13:46:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// nsIObserver
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
VacuumManager::Observe(nsISupports *aSubject,
|
|
|
|
const char *aTopic,
|
2014-01-04 15:02:17 +00:00
|
|
|
const char16_t *aData)
|
2010-10-19 13:46:49 +00:00
|
|
|
{
|
|
|
|
if (strcmp(aTopic, OBSERVER_TOPIC_IDLE_DAILY) == 0) {
|
|
|
|
// Try to run vacuum on all registered entries. Will stop at the first
|
|
|
|
// successful one.
|
2013-10-10 12:48:03 +00:00
|
|
|
nsCOMArray<mozIStorageVacuumParticipant> entries;
|
|
|
|
mParticipants.GetEntries(entries);
|
2010-10-19 13:46:49 +00:00
|
|
|
// If there are more entries than what a month can contain, we could end up
|
|
|
|
// skipping some, since we run daily. So we use a starting index.
|
2011-06-02 01:05:12 +00:00
|
|
|
static const char* kPrefName = PREF_VACUUM_BRANCH "index";
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t startIndex = Preferences::GetInt(kPrefName, 0);
|
2010-10-19 13:46:49 +00:00
|
|
|
if (startIndex >= entries.Count()) {
|
|
|
|
startIndex = 0;
|
|
|
|
}
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t index;
|
2010-10-19 13:46:49 +00:00
|
|
|
for (index = startIndex; index < entries.Count(); ++index) {
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<Vacuumer> vacuum = new Vacuumer(entries[index]);
|
2010-10-19 13:46:49 +00:00
|
|
|
// Only vacuum one database per day.
|
|
|
|
if (vacuum->execute()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-02-22 11:23:05 +00:00
|
|
|
DebugOnly<nsresult> rv = Preferences::SetInt(kPrefName, index);
|
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv), "Should be able to set a preference");
|
2010-10-19 13:46:49 +00:00
|
|
|
}
|
2010-10-19 13:46:51 +00:00
|
|
|
|
2010-10-19 13:46:49 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace storage
|
|
|
|
} // namespace mozilla
|