Back out changeset 0b3af3fef0fd (bug 580790) due to burnage on a CLOSED TREE
authorShawn Wilsher <sdwilsh@shawnwilsher.com>
Fri, 06 Aug 2010 10:45:16 -0700
changeset 49055 8d4d8fc43475a18933f6d48e2260289d9cff0db9
parent 49052 0b3af3fef0fdfeb5e696c13d773d352e56d94b12
child 49056 ed1fdc1c5c7b010f74a1657f80fb509f42ce81ed
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs580790
milestone2.0b4pre
backs out0b3af3fef0fdfeb5e696c13d773d352e56d94b12
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
Back out changeset 0b3af3fef0fd (bug 580790) due to burnage on a CLOSED TREE
storage/src/mozStorageConnection.cpp
storage/src/mozStorageService.cpp
storage/src/mozStorageService.h
--- a/storage/src/mozStorageConnection.cpp
+++ b/storage/src/mozStorageConnection.cpp
@@ -43,16 +43,18 @@
 
 #include <stdio.h>
 
 #include "nsError.h"
 #include "nsIMutableArray.h"
 #include "nsHashSets.h"
 #include "nsAutoPtr.h"
 #include "nsIFile.h"
+#include "nsIPrefService.h"
+#include "nsIPrefBranch.h"
 #include "nsThreadUtils.h"
 #include "nsAutoLock.h"
 
 #include "mozIStorageAggregateFunction.h"
 #include "mozIStorageCompletionCallback.h"
 #include "mozIStorageFunction.h"
 
 #include "mozStorageAsyncStatementExecution.h"
@@ -72,16 +74,18 @@
 
 #ifdef PR_LOGGING
 PRLogModuleInfo* gStorageLog = nsnull;
 #endif
 
 namespace mozilla {
 namespace storage {
 
+#define PREF_TS_SYNCHRONOUS "toolkit.storage.synchronous"
+
 ////////////////////////////////////////////////////////////////////////////////
 //// Variant Specialization Functions (variantToSQLiteT)
 
 static int
 sqlite3_T_int(sqlite3_context *aCtx,
               int aValue)
 {
   ::sqlite3_result_int(aCtx, aValue);
@@ -428,18 +432,23 @@ Connection::initialize(nsIFile *aDatabas
 
   if (srv != SQLITE_OK) {
     ::sqlite3_close(mDBConn);
     mDBConn = nsnull;
 
     return convertResultCode(srv);
   }
 
-  // Set the synchronous PRAGMA, according to the preference.
-  switch (Service::getSynchronousPref()) {
+  // Set the synchronous PRAGMA, according to the pref
+  nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID));
+  PRInt32 synchronous = 1; // Default to NORMAL if pref not set
+  if (pref)
+    (void)pref->GetIntPref(PREF_TS_SYNCHRONOUS, &synchronous);
+
+  switch (synchronous) {
     case 2:
       (void)ExecuteSimpleSQL(NS_LITERAL_CSTRING(
           "PRAGMA synchronous = FULL;"));
       break;
     case 0:
       (void)ExecuteSimpleSQL(NS_LITERAL_CSTRING(
           "PRAGMA synchronous = OFF;"));
       break;
--- a/storage/src/mozStorageService.cpp
+++ b/storage/src/mozStorageService.cpp
@@ -37,43 +37,35 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozStorageService.h"
 #include "mozStorageConnection.h"
-#include "pratom.h"
+#include "prinit.h"
 #include "nsAutoPtr.h"
 #include "nsCollationCID.h"
 #include "nsEmbedCID.h"
 #include "nsThreadUtils.h"
 #include "mozStoragePrivateHelpers.h"
 #include "nsILocale.h"
 #include "nsILocaleService.h"
 #include "nsIXPConnect.h"
 #include "nsIObserverService.h"
 #include "mozilla/Services.h"
-#include "nsIPrefService.h"
-#include "nsIPrefBranch.h"
 
 #include "sqlite3.h"
 
 #include "nsIPromptService.h"
 #include "nsIMemoryReporter.h"
 
 #include "mozilla/FunctionTimer.h"
 
-////////////////////////////////////////////////////////////////////////////////
-//// Defines
-
-#define PREF_TS_SYNCHRONOUS "toolkit.storage.synchronous"
-#define PREF_TS_SYNCHRONOUS_DEFAULT 1
-
 namespace mozilla {
 namespace storage {
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Memory Reporting
 
 static PRInt64
 GetStorageSQLitePageCacheMemoryUsed(void *)
@@ -107,21 +99,19 @@ NS_MEMORY_REPORTER_IMPLEMENT(StorageSQLi
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Helpers
 
 class ServiceMainThreadInitializer : public nsRunnable
 {
 public:
   ServiceMainThreadInitializer(nsIObserver *aObserver,
-                               nsIXPConnect **aXPConnectPtr,
-                               PRInt32 *aSynchronousPrefValPtr)
+                               nsIXPConnect **aXPConnectPtr)
   : mObserver(aObserver)
   , mXPConnectPtr(aXPConnectPtr)
-  , mSynchronousPrefValPtr(aSynchronousPrefValPtr)
   {
   }
 
   NS_IMETHOD Run()
   {
     NS_PRECONDITION(NS_IsMainThread(), "Must be running on the main thread!");
 
     // NOTE:  All code that can only run on the main thread and needs to be run
@@ -137,37 +127,27 @@ public:
     NS_ENSURE_TRUE(os, NS_ERROR_FAILURE);
     nsresult rv = os->AddObserver(mObserver, "xpcom-shutdown", PR_FALSE);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // We cache XPConnect for our language helpers.  XPConnect can only be
     // used on the main thread.
     (void)CallGetService(nsIXPConnect::GetCID(), mXPConnectPtr);
 
-    // We need to obtain the toolkit.storage.synchronous 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.
-    nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID));
-    PRInt32 synchronous = PREF_TS_SYNCHRONOUS_DEFAULT;
-    if (pref)
-      (void)pref->GetIntPref(PREF_TS_SYNCHRONOUS, &synchronous);
-    ::PR_AtomicSet(mSynchronousPrefValPtr, synchronous);
-
     // Register our SQLite memory reporters.  Registration can only happen on
     // the main thread (otherwise you'll get cryptic crashes).
     NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(StorageSQLitePageCacheMemoryUsed));
     NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(StorageSQLiteOtherMemoryUsed));
 
     return NS_OK;
   }
 
 private:
   nsIObserver *mObserver;
   nsIXPConnect **mXPConnectPtr;
-  PRInt32 *mSynchronousPrefValPtr;
 };
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Service
 
 NS_IMPL_THREADSAFE_ISUPPORTS2(
   Service,
   mozIStorageService,
@@ -207,17 +187,16 @@ Service::getSingleton()
       NS_RELEASE(gService);
   }
 
   return gService;
 }
 
 nsIXPConnect *Service::sXPConnect = nsnull;
 
-// static
 already_AddRefed<nsIXPConnect>
 Service::getXPConnect()
 {
   NS_PRECONDITION(NS_IsMainThread(),
                   "Must only get XPConnect on the main thread!");
   NS_PRECONDITION(gService,
                   "Can not get XPConnect without an instance of our service!");
 
@@ -225,25 +204,16 @@ Service::getXPConnect()
   // not cache the service after this point.
   nsCOMPtr<nsIXPConnect> xpc(sXPConnect);
   if (!xpc)
     xpc = do_GetService(nsIXPConnect::GetCID());
   NS_ASSERTION(xpc, "Could not get XPConnect!");
   return xpc.forget();
 }
 
-PRInt32 Service::sSynchronousPref;
-
-// static
-PRInt32
-Service::getSynchronousPref()
-{
-  return sSynchronousPref;
-}
-
 Service::Service()
 : mMutex("Service::mMutex")
 {
 }
 
 Service::~Service()
 {
   // Shutdown the sqlite3 API.  Warn if shutdown did not turn out okay, but
@@ -282,23 +252,19 @@ Service::initialize()
   // cache.  We do not need to lock here with mMutex because this function is
   // only ever called from Service::GetSingleton, which will only
   // call this function once, and will not return until this function returns.
   // (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);
 
-  // Set the default value for the toolkit.storage.synchronous pref.  It will be
-  // updated with the user preference on the main thread.
-  sSynchronousPref = PREF_TS_SYNCHRONOUS_DEFAULT;
-
   // Run the things that need to run on the main thread there.
   nsCOMPtr<nsIRunnable> event =
-    new ServiceMainThreadInitializer(this, &sXPConnect, &sSynchronousPref);
+    new ServiceMainThreadInitializer(this, &sXPConnect);
   if (event && ::NS_IsMainThread()) {
     (void)event->Run();
   }
   else {
     (void)::NS_DispatchToMainThread(event);
   }
 
   return NS_OK;
--- a/storage/src/mozStorageService.h
+++ b/storage/src/mozStorageService.h
@@ -89,21 +89,16 @@ public:
   NS_DECL_NSIOBSERVER
 
   /**
    * Obtains an already AddRefed pointer to XPConnect.  This is used by
    * language helpers.
    */
   static already_AddRefed<nsIXPConnect> getXPConnect();
 
-  /**
-   * Obtains the cached data for the toolkit.storage.synchronous preference.
-   */
-  static PRInt32 getSynchronousPref();
-
 private:
   Service();
   virtual ~Service();
 
   /**
    * Used for 1) locking around calls when initializing connections so that we
    * can ensure that the state of sqlite3_enable_shared_cache is sane and 2)
    * synchronizing access to mLocaleCollation.
@@ -133,16 +128,14 @@ private:
    */
   nsCOMPtr<nsICollation> mLocaleCollation;
 
   nsCOMPtr<nsIFile> mProfileStorageFile;
 
   static Service *gService;
 
   static nsIXPConnect *sXPConnect;
-
-  static PRInt32 sSynchronousPref;
 };
 
 } // namespace storage
 } // namespace mozilla
 
 #endif /* MOZSTORAGESERVICE_H */