Bug 831193 (part 6) - Don't use NS_MEMORY_REPORTER_IMPLEMENT in mozStorageService.cpp. r=mak.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 17 Jan 2013 16:45:11 -0800
changeset 144645 7121f9f524ee1bc42b8d3f2b8409767993ed34ce
parent 144644 f6b1120fe7f248d5eec1ec6e621bfb8a83a067e2
child 144646 24791c073aeee2fd1af5199c4bc6e9c3b6425a3b
push id33045
push usernnethercote@mozilla.com
push dateWed, 28 Aug 2013 08:59:06 +0000
treeherdermozilla-inbound@eead1e72622d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs831193
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 831193 (part 6) - Don't use NS_MEMORY_REPORTER_IMPLEMENT in mozStorageService.cpp. r=mak.
storage/src/mozStorageService.cpp
--- a/storage/src/mozStorageService.cpp
+++ b/storage/src/mozStorageService.cpp
@@ -48,45 +48,43 @@
 #define PREF_TS_PAGESIZE_DEFAULT 32768
 
 namespace mozilla {
 namespace storage {
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Memory Reporting
 
-static int64_t
-GetStorageSQLiteMemoryUsed()
-{
-  return ::sqlite3_memory_used();
-}
-
 // We don't need an "explicit" reporter for total SQLite memory usage, because
 // the multi-reporter provides reports that add up to the total.  But it's
 // useful to have the total in the "Other Measurements" list in about:memory,
 // and more importantly, we also gather the total via telemetry.
-NS_MEMORY_REPORTER_IMPLEMENT(StorageSQLite,
-    "storage-sqlite",
-    KIND_OTHER,
-    UNITS_BYTES,
-    GetStorageSQLiteMemoryUsed,
-    "Memory used by SQLite.")
+class StorageSQLiteReporter MOZ_FINAL : public MemoryReporterBase
+{
+public:
+  StorageSQLiteReporter()
+    : MemoryReporterBase("storage-sqlite", KIND_OTHER, UNITS_BYTES,
+                         "Memory used by SQLite.")
+  {}
+private:
+  int64_t Amount() MOZ_OVERRIDE { return ::sqlite3_memory_used(); }
+};
 
 class StorageSQLiteMultiReporter MOZ_FINAL : public nsIMemoryMultiReporter
 {
 private:
   Service *mService;    // a weakref because Service contains a strongref to this
   nsCString mStmtDesc;
   nsCString mCacheDesc;
   nsCString mSchemaDesc;
 
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
 
-  StorageSQLiteMultiReporter(Service *aService) 
+  StorageSQLiteMultiReporter(Service *aService)
   : mService(aService)
   {
     mStmtDesc = NS_LITERAL_CSTRING(
       "Memory (approximate) used by all prepared statements used by "
       "connections to this database.");
 
     mCacheDesc = NS_LITERAL_CSTRING(
       "Memory (approximate) used by all pager caches used by connections "
@@ -300,18 +298,16 @@ Service::getSynchronousPref()
 
 int32_t Service::sDefaultPageSize = PREF_TS_PAGESIZE_DEFAULT;
 
 Service::Service()
 : mMutex("Service::mMutex")
 , mSqliteVFS(nullptr)
 , mRegistrationMutex("Service::mRegistrationMutex")
 , mConnections()
-, mStorageSQLiteReporter(nullptr)
-, mStorageSQLiteMultiReporter(nullptr)
 {
 }
 
 Service::~Service()
 {
   (void)::NS_UnregisterMemoryReporter(mStorageSQLiteReporter);
   (void)::NS_UnregisterMemoryMultiReporter(mStorageSQLiteMultiReporter);
 
@@ -540,17 +536,17 @@ Service::initialize()
   // We need to obtain the toolkit.storage.pageSize preferences on the main
   // thread because the preference service can only be accessed there.  This
   // is cached in the service for all future Open[Unshared]Database calls.
   sDefaultPageSize =
       Preferences::GetInt(PREF_TS_PAGESIZE, PREF_TS_PAGESIZE_DEFAULT);
 
   // Create and register our SQLite memory reporters.  Registration can only
   // happen on the main thread (otherwise you'll get cryptic crashes).
-  mStorageSQLiteReporter = new NS_MEMORY_REPORTER_NAME(StorageSQLite);
+  mStorageSQLiteReporter = new StorageSQLiteReporter();
   mStorageSQLiteMultiReporter = new StorageSQLiteMultiReporter(this);
   (void)::NS_RegisterMemoryReporter(mStorageSQLiteReporter);
   (void)::NS_RegisterMemoryMultiReporter(mStorageSQLiteMultiReporter);
 
   return NS_OK;
 }
 
 int