Bug 858680 - Part 3: Allow mozStorage to access the dbstats virtual table, r=asuth.
☠☠ backed out by 4e15a4c0c77a ☠ ☠
authorBen Turner <bent.mozilla@gmail.com>
Thu, 30 Apr 2015 16:30:57 -0700
changeset 266186 6435d5aab611f947045475beb02ae01216cf29ab
parent 266185 0aaa67fc61e817e1a0e9f4f810dba2b33b238bff
child 266187 ca9c2b05d6595eab2bb8de8ccd8cda3861e33538
push id2231
push usermichael.l.comella@gmail.com
push dateFri, 22 May 2015 20:04:59 +0000
reviewersasuth
bugs858680
milestone41.0a1
Bug 858680 - Part 3: Allow mozStorage to access the dbstats virtual table, r=asuth.
db/sqlite3/src/sqlite.def
storage/mozStorageConnection.cpp
--- a/db/sqlite3/src/sqlite.def
+++ b/db/sqlite3/src/sqlite.def
@@ -46,16 +46,17 @@ EXPORTS
         sqlite3_complete16
         sqlite3_config
         sqlite3_create_collation
         sqlite3_create_collation16
         sqlite3_create_function
         sqlite3_create_function16
         sqlite3_create_module
         sqlite3_data_count
+        sqlite3_dbstat_register
         sqlite3_db_filename
         sqlite3_db_handle
         sqlite3_db_mutex
         sqlite3_db_status
         sqlite3_declare_vtab
         sqlite3_enable_load_extension
         sqlite3_enable_shared_cache
         sqlite3_errcode
--- a/storage/mozStorageConnection.cpp
+++ b/storage/mozStorageConnection.cpp
@@ -57,16 +57,20 @@ PRLogModuleInfo* gStorageLog = nullptr;
     nsCOMPtr<nsIThread> mainThread = do_GetMainThread(); \
     NS_WARN_IF_FALSE(threadOpenedOn == mainThread || !NS_IsMainThread(), \
                "Using Storage synchronous API on main-thread, but the connection was opened on another thread."); \
   } while(0)
 #else
 #define CHECK_MAINTHREAD_ABUSE() do { /* Nothing */ } while(0)
 #endif
 
+extern "C" {
+int sqlite3_dbstat_register(sqlite3 *db);
+}
+
 namespace mozilla {
 namespace storage {
 
 namespace {
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Variant Specialization Functions (variantToSQLiteT)
 
@@ -139,17 +143,24 @@ sqlite3_T_blob(sqlite3_context *aCtx,
 
 struct Module
 {
   const char* name;
   int (*registerFunc)(sqlite3*, const char*);
 };
 
 Module gModules[] = {
-  { "filesystem", RegisterFileSystemModule }
+  { "filesystem", RegisterFileSystemModule },
+  { "dbstat",
+    [](sqlite3* aDatabase, const char* aName) -> int
+    {
+      MOZ_ASSERT(!strcmp(aName, "dbstat"));
+      return sqlite3_dbstat_register(aDatabase);
+    }
+  }
 };
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Local Functions
 
 void tracefunc (void *aClosure, const char *aStmt)
 {
   PR_LOG(gStorageLog, PR_LOG_DEBUG, ("sqlite3_trace on %p for '%s'", aClosure,