Bug 489612 - Update mozStoragePrivateHelpers.* to follow style guidelines

Consistent spacing, consistent naming, and namespaces - OH MY!
r=asuth
This commit is contained in:
Shawn Wilsher 2009-05-08 20:29:56 -04:00
parent b139ffaf75
commit 6f67edf0cc
6 changed files with 51 additions and 40 deletions

View File

@ -317,7 +317,7 @@ AsyncExecuteStatements::executeAndProcessStatement(sqlite3_stmt *aStatement,
#ifdef DEBUG
// Check to make sure that this statement was smart about what it did.
CheckAndLogStatementPerformance(aStatement);
checkAndLogStatementPerformance(aStatement);
#endif
// If we are done, we need to set our state accordingly while we still hold

View File

@ -351,7 +351,7 @@ Connection::initialize(nsIFile *aDatabaseFile)
}
if (srv != SQLITE_OK) {
mDBConn = nsnull;
return ConvertResultCode(srv);
return convertResultCode(srv);
}
#ifdef PR_LOGGING
@ -370,7 +370,7 @@ Connection::initialize(nsIFile *aDatabaseFile)
// Register our built-in SQL functions.
if (registerFunctions(mDBConn) != SQLITE_OK) {
mDBConn = nsnull;
return ConvertResultCode(srv);
return convertResultCode(srv);
}
// Execute a dummy statement to force the db open, and to verify if it is
@ -390,7 +390,7 @@ Connection::initialize(nsIFile *aDatabaseFile)
::sqlite3_close(mDBConn);
mDBConn = nsnull;
return ConvertResultCode(srv);
return convertResultCode(srv);
}
// Set the synchronous PRAGMA, according to the pref
@ -441,7 +441,7 @@ Connection::databaseElementExists(enum DatabaseElementType aElementType,
sqlite3_stmt *stmt;
int srv = ::sqlite3_prepare_v2(mDBConn, query.get(), -1, &stmt, NULL);
if (srv != SQLITE_OK)
return ConvertResultCode(srv);
return convertResultCode(srv);
srv = ::sqlite3_step(stmt);
// we just care about the return value from step
@ -456,7 +456,7 @@ Connection::databaseElementExists(enum DatabaseElementType aElementType,
return NS_OK;
}
return ConvertResultCode(srv);
return convertResultCode(srv);
}
bool
@ -541,7 +541,7 @@ Connection::Close()
NS_ERROR("sqlite3_close failed. There are probably outstanding statements that are listed above!");
mDBConn = NULL;
return ConvertResultCode(srv);
return convertResultCode(srv);
}
NS_IMETHODIMP
@ -648,7 +648,7 @@ Connection::ExecuteSimpleSQL(const nsACString &aSQLStatement)
int srv = ::sqlite3_exec(mDBConn, PromiseFlatCString(aSQLStatement).get(),
NULL, NULL, NULL);
return ConvertResultCode(srv);
return convertResultCode(srv);
}
nsresult
@ -705,7 +705,7 @@ Connection::ExecuteAsync(mozIStorageStatement **aStatements,
(void)::sqlite3_finalize(stmts[i]);
if (rc != SQLITE_OK)
rv = ConvertResultCode(rc);
rv = convertResultCode(rc);
}
// Always reset all the statements
@ -805,7 +805,7 @@ Connection::CreateTable(const char *aTableName,
int srv = ::sqlite3_exec(mDBConn, buf, NULL, NULL, NULL);
::PR_smprintf_free(buf);
return ConvertResultCode(srv);
return convertResultCode(srv);
}
NS_IMETHODIMP
@ -829,7 +829,7 @@ Connection::CreateFunction(const nsACString &aFunctionName,
NULL,
NULL);
if (srv != SQLITE_OK)
return ConvertResultCode(srv);
return convertResultCode(srv);
NS_ENSURE_TRUE(mFunctions.Put(aFunctionName, aFunction),
NS_ERROR_OUT_OF_MEMORY);
@ -862,7 +862,7 @@ Connection::CreateAggregateFunction(const nsACString &aFunctionName,
aggregateFunctionStepHelper,
aggregateFunctionFinalHelper);
if (srv != SQLITE_OK)
return ConvertResultCode(srv);
return convertResultCode(srv);
NS_ENSURE_TRUE(mFunctions.Put(aFunctionName, aFunction),
NS_ERROR_OUT_OF_MEMORY);
@ -887,7 +887,7 @@ Connection::RemoveFunction(const nsACString &aFunctionName)
NULL,
NULL);
if (srv != SQLITE_OK)
return ConvertResultCode(srv);
return convertResultCode(srv);
mFunctions.Remove(aFunctionName);

View File

@ -46,8 +46,11 @@
#include "mozStoragePrivateHelpers.h"
namespace mozilla {
namespace storage {
nsresult
ConvertResultCode(int aSQLiteResultCode)
convertResultCode(int aSQLiteResultCode)
{
switch (aSQLiteResultCode) {
case SQLITE_OK:
@ -85,18 +88,18 @@ ConvertResultCode(int aSQLiteResultCode)
}
void
CheckAndLogStatementPerformance(sqlite3_stmt *aStatement)
checkAndLogStatementPerformance(sqlite3_stmt *aStatement)
{
// Check to see if the query performed sorting operations or not. If it
// did, it may need to be optimized!
int count = sqlite3_stmt_status(aStatement, SQLITE_STMTSTATUS_SORT, 1);
int count = ::sqlite3_stmt_status(aStatement, SQLITE_STMTSTATUS_SORT, 1);
if (count <= 0)
return;
const char *sql = sqlite3_sql(aStatement);
const char *sql = ::sqlite3_sql(aStatement);
// Check to see if this is marked to not warn
if (strstr(sql, "/* do not warn (bug "))
if (::strstr(sql, "/* do not warn (bug "))
return;
nsCAutoString message;
@ -112,3 +115,6 @@ CheckAndLogStatementPerformance(sqlite3_stmt *aStatement)
"details.");
NS_WARNING(message.get());
}
} // namespace storage
} // namespace mozilla

View File

@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 sts=4
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -38,8 +38,8 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef _MOZSTORAGEPRIVATEHELPERS_H_
#define _MOZSTORAGEPRIVATEHELPERS_H_
#ifndef _mozStoragePrivateHelpers_h_
#define _mozStoragePrivateHelpers_h_
#include "mozStorage.h"
@ -47,6 +47,9 @@
* This file contains convenience methods for mozStorage.
*/
namespace mozilla {
namespace storage {
/**
* Converts a SQLite return code to an nsresult return code.
*
@ -54,7 +57,7 @@
* The SQLite return code to convert.
* @returns the corresponding nsresult code for aSQLiteResultCode.
*/
nsresult ConvertResultCode(int aSQLiteResultCode);
nsresult convertResultCode(int aSQLiteResultCode);
/**
* Checks the performance of a SQLite statement and logs a warning with
@ -65,7 +68,9 @@ nsresult ConvertResultCode(int aSQLiteResultCode);
* @param aStatement
* The sqlite3_stmt object to check.
*/
void CheckAndLogStatementPerformance(sqlite3_stmt *aStatement);
void checkAndLogStatementPerformance(sqlite3_stmt *aStatement);
#endif // _MOZSTORAGEPRIVATEHELPERS_H_
} // namespace storage
} // namespace mozilla
#endif // _mozStoragePrivateHelpers_h_

View File

@ -147,14 +147,14 @@ Service::initialize()
// effect.
int rc = ::sqlite3_config(SQLITE_CONFIG_MEMSTATUS, 0);
if (rc != SQLITE_OK)
return ConvertResultCode(rc);
return convertResultCode(rc);
// Explicitly initialize sqlite3. Although this is implicitly called by
// various sqlite3 functions (and the sqlite3_open calls in our case),
// the documentation suggests calling this directly. So we do.
rc = ::sqlite3_initialize();
if (rc != SQLITE_OK)
return ConvertResultCode(rc);
return convertResultCode(rc);
// This makes multiple connections to the same database share the same pager
// cache. We do not need to lock here with mLock because this function is
@ -163,7 +163,7 @@ Service::initialize()
// (It does not matter where this is called relative to sqlite3_initialize.)
rc = ::sqlite3_enable_shared_cache(1);
if (rc != SQLITE_OK)
return ConvertResultCode(rc);
return convertResultCode(rc);
nsCOMPtr<nsIObserverService> os =
do_GetService("@mozilla.org/observer-service;1");
@ -255,13 +255,13 @@ Service::OpenUnsharedDatabase(nsIFile *aDatabaseFile,
nsAutoLock lock(mLock);
int rc = ::sqlite3_enable_shared_cache(0);
if (rc != SQLITE_OK)
return ConvertResultCode(rc);
return convertResultCode(rc);
rv = msc->initialize(aDatabaseFile);
rc = ::sqlite3_enable_shared_cache(1);
if (rc != SQLITE_OK)
return ConvertResultCode(rc);
return convertResultCode(rc);
}
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -325,7 +325,7 @@ mozStorageStatement::Finalize()
mStatementRowHolder = nsnull;
}
return ConvertResultCode(srv);
return convertResultCode(srv);
}
/* readonly attribute unsigned long parameterCount; */
@ -447,7 +447,7 @@ mozStorageStatement::Reset()
PR_LOG(gStorageLog, PR_LOG_DEBUG, ("Resetting statement: '%s'",
sqlite3_sql(mDBStatement)));
CheckAndLogStatementPerformance(mDBStatement);
checkAndLogStatementPerformance(mDBStatement);
#endif
sqlite3_reset(mDBStatement);
@ -469,7 +469,7 @@ mozStorageStatement::BindUTF8StringParameter(PRUint32 aParamIndex, const nsACStr
nsPromiseFlatCString(aValue).get(),
aValue.Length(), SQLITE_TRANSIENT);
return ConvertResultCode(srv);
return convertResultCode(srv);
}
/* void bindStringParameter (in unsigned long aParamIndex, in AString aValue); */
@ -483,7 +483,7 @@ mozStorageStatement::BindStringParameter(PRUint32 aParamIndex, const nsAString &
nsPromiseFlatString(aValue).get(),
aValue.Length() * 2, SQLITE_TRANSIENT);
return ConvertResultCode(srv);
return convertResultCode(srv);
}
/* void bindDoubleParameter (in unsigned long aParamIndex, in double aValue); */
@ -495,7 +495,7 @@ mozStorageStatement::BindDoubleParameter(PRUint32 aParamIndex, double aValue)
int srv = sqlite3_bind_double (mDBStatement, aParamIndex + 1, aValue);
return ConvertResultCode(srv);
return convertResultCode(srv);
}
/* void bindInt32Parameter (in unsigned long aParamIndex, in long aValue); */
@ -507,7 +507,7 @@ mozStorageStatement::BindInt32Parameter(PRUint32 aParamIndex, PRInt32 aValue)
int srv = sqlite3_bind_int (mDBStatement, aParamIndex + 1, aValue);
return ConvertResultCode(srv);
return convertResultCode(srv);
}
/* void bindInt64Parameter (in unsigned long aParamIndex, in long long aValue); */
@ -519,7 +519,7 @@ mozStorageStatement::BindInt64Parameter(PRUint32 aParamIndex, PRInt64 aValue)
int srv = sqlite3_bind_int64 (mDBStatement, aParamIndex + 1, aValue);
return ConvertResultCode(srv);
return convertResultCode(srv);
}
/* void bindNullParameter (in unsigned long aParamIndex); */
@ -531,7 +531,7 @@ mozStorageStatement::BindNullParameter(PRUint32 aParamIndex)
int srv = sqlite3_bind_null (mDBStatement, aParamIndex + 1);
return ConvertResultCode(srv);
return convertResultCode(srv);
}
/* void bindBlobParameter (in unsigned long aParamIndex, [array, const, size_is (aValueSize)] in octet aValue, in unsigned long aValueSize); */
@ -544,7 +544,7 @@ mozStorageStatement::BindBlobParameter(PRUint32 aParamIndex, const PRUint8 *aVal
int srv = sqlite3_bind_blob (mDBStatement, aParamIndex + 1, aValue,
aValueSize, SQLITE_TRANSIENT);
return ConvertResultCode(srv);
return convertResultCode(srv);
}
/* void execute (); */
@ -599,7 +599,7 @@ mozStorageStatement::ExecuteStep(PRBool *_retval)
mExecuting = PR_FALSE;
}
return ConvertResultCode(srv);
return convertResultCode(srv);
}
/* nsICancelable executeAsync([optional] in storageIStatementCallback aCallback); */