Bug 693469 - Implement mozilla::ArrayLength and mozilla::ArrayEnd, and replace uses of NS_ARRAY_LENGTH whenever possible. (Exceptions: assigning to static initializers, use in static assertions, as template parameters, etc. These will go away when the relevant compilers have C++11 constexpr support.) r=cjones
This commit is contained in:
23
netwerk/cache/nsDiskCacheDeviceSQL.cpp
vendored
23
netwerk/cache/nsDiskCacheDeviceSQL.cpp
vendored
@@ -37,6 +37,8 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "mozilla/Util.h"
|
||||
|
||||
#include "nsCache.h"
|
||||
#include "nsDiskCache.h"
|
||||
#include "nsDiskCacheDeviceSQL.h"
|
||||
@@ -67,6 +69,8 @@
|
||||
|
||||
#include "mozilla/FunctionTimer.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
static const char OFFLINE_CACHE_DEVICE_ID[] = { "offline" };
|
||||
static NS_DEFINE_CID(kCacheServiceCID, NS_CACHESERVICE_CID);
|
||||
|
||||
@@ -1002,6 +1006,16 @@ nsOfflineCacheDevice::GetInstance()
|
||||
return cacheService->mOfflineDevice;
|
||||
}
|
||||
|
||||
// This struct is local to nsOfflineCacheDevice::Init, but ISO C++98 doesn't
|
||||
// allow a template (mozilla::ArrayLength) to be instantiated based on a local
|
||||
// type. Boo-urns!
|
||||
struct StatementSql {
|
||||
nsCOMPtr<mozIStorageStatement> &statement;
|
||||
const char *sql;
|
||||
StatementSql (nsCOMPtr<mozIStorageStatement> &aStatement, const char *aSql):
|
||||
statement (aStatement), sql (aSql) {}
|
||||
};
|
||||
|
||||
nsresult
|
||||
nsOfflineCacheDevice::Init()
|
||||
{
|
||||
@@ -1129,12 +1143,7 @@ nsOfflineCacheDevice::Init()
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// create all (most) of our statements up front
|
||||
struct StatementSql {
|
||||
nsCOMPtr<mozIStorageStatement> &statement;
|
||||
const char *sql;
|
||||
StatementSql (nsCOMPtr<mozIStorageStatement> &aStatement, const char *aSql):
|
||||
statement (aStatement), sql (aSql) {}
|
||||
} prepared[] = {
|
||||
StatementSql prepared[] = {
|
||||
StatementSql ( mStatement_CacheSize, "SELECT Sum(DataSize) from moz_cache;" ),
|
||||
StatementSql ( mStatement_ApplicationCacheSize, "SELECT Sum(DataSize) from moz_cache WHERE ClientID = ?;" ),
|
||||
StatementSql ( mStatement_EntryCount, "SELECT count(*) from moz_cache;" ),
|
||||
@@ -1169,7 +1178,7 @@ nsOfflineCacheDevice::Init()
|
||||
StatementSql ( mStatement_InsertNamespaceEntry, "INSERT INTO moz_cache_namespaces (ClientID, NameSpace, Data, ItemType) VALUES(?, ?, ?, ?);"),
|
||||
StatementSql ( mStatement_EnumerateGroups, "SELECT GroupID, ActiveClientID FROM moz_cache_groups;")
|
||||
};
|
||||
for (PRUint32 i = 0; NS_SUCCEEDED(rv) && i < NS_ARRAY_LENGTH(prepared); ++i)
|
||||
for (PRUint32 i = 0; NS_SUCCEEDED(rv) && i < ArrayLength(prepared); ++i)
|
||||
{
|
||||
LOG(("Creating statement: %s\n", prepared[i].sql));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user