Merge services-central with mozilla-central. a=merge
authorPhilipp von Weitershausen <philipp@weitershausen.de>
Sat, 26 Feb 2011 00:31:54 -0800
changeset 63128 d708c2fa7fea7b3d5517c3d3122dcdd6b7687ef8
parent 63127 f20f6ca6be78703dad7c22df9f274c4ede9885d1 (current diff)
parent 63117 2b4767713e826e4934c606be4d30dbb962aeff10 (diff)
child 63129 7dc677aafff8af7ac1ca80efc17156e599a0ef70
push id19035
push userpweitershausen@mozilla.com
push dateSat, 26 Feb 2011 08:32:57 +0000
treeherdermozilla-central@d708c2fa7fea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone2.0b13pre
first release with
nightly linux32
d708c2fa7fea / 4.0b13pre / 20110226030401 / files
nightly linux64
d708c2fa7fea / 4.0b13pre / 20110226030401 / files
nightly mac
d708c2fa7fea / 4.0b13pre / 20110226030401 / files
nightly win32
d708c2fa7fea / 4.0b13pre / 20110226030401 / files
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
Merge services-central with mozilla-central. a=merge
--- a/content/base/src/nsFrameMessageManager.cpp
+++ b/content/base/src/nsFrameMessageManager.cpp
@@ -608,17 +608,17 @@ nsFrameScriptExecutor::Shutdown()
 
     sScriptCacheCleaner = nsnull;
   }
 }
 
 void
 nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL)
 {
-  if (!mGlobal || !mCx) {
+  if (!mGlobal || !mCx || !sCachedScripts) {
     return;
   }
 
   nsFrameScriptExecutorJSObjectHolder* holder = sCachedScripts->Get(aURL);
   if (holder) {
     nsContentUtils::ThreadJSContextStack()->Push(mCx);
     {
       // Need to scope JSAutoRequest to happen after Push but before Pop,
--- a/storage/src/mozStorageAsyncStatementExecution.cpp
+++ b/storage/src/mozStorageAsyncStatementExecution.cpp
@@ -421,17 +421,17 @@ AsyncExecuteStatements::notifyComplete()
   mMutex.AssertNotCurrentThreadOwns();
   NS_ASSERTION(mState != PENDING,
                "Still in a pending state when calling Complete!");
 
   // Finalize our statements before we try to commit or rollback.  If we are
   // canceling and have statements that think they have pending work, the
   // rollback will fail.
   for (PRUint32 i = 0; i < mStatements.Length(); i++)
-    mStatements[i].finalize();
+    mStatements[i].finalize(mCallingThread);
 
   // Handle our transaction, if we have one
   if (mTransactionManager) {
     if (mState == COMPLETED) {
       nsresult rv = mTransactionManager->Commit();
       if (NS_FAILED(rv)) {
         mState = ERROR;
         (void)notifyError(mozIStorageError::ERROR,
--- a/storage/src/mozStorageStatementData.h
+++ b/storage/src/mozStorageStatementData.h
@@ -11,17 +11,17 @@
  * Software distributed under the License is distributed on an "AS IS" basis,
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  * for the specific language governing rights and limitations under the
  * License.
  *
  * The Original Code is mozilla.org code.
  *
  * The Initial Developer of the Original Code is
- * Mozilla Corporation.
+ * the Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Shawn Wilsher <me@shawnwilsher.com> (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -39,16 +39,18 @@
 
 #ifndef mozStorageStatementData_h
 #define mozStorageStatementData_h
 
 #include "sqlite3.h"
 
 #include "nsAutoPtr.h"
 #include "nsTArray.h"
+#include "nsIEventTarget.h"
+#include "nsProxyRelease.h"
 
 #include "mozStorageBindingParamsArray.h"
 #include "mozIStorageBaseStatement.h"
 #include "mozStorageConnection.h"
 #include "StorageBaseStatementInternal.h"
 
 struct sqlite3_stmt;
 
@@ -60,22 +62,24 @@ class StatementData
 public:
   StatementData(sqlite3_stmt *aStatement,
                 already_AddRefed<BindingParamsArray> aParamsArray,
                 StorageBaseStatementInternal *aStatementOwner)
   : mStatement(aStatement)
   , mParamsArray(aParamsArray)
   , mStatementOwner(aStatementOwner)
   {
+    NS_PRECONDITION(mStatementOwner, "Must have a statement owner!");
   }
   StatementData(const StatementData &aSource)
   : mStatement(aSource.mStatement)
   , mParamsArray(aSource.mParamsArray)
   , mStatementOwner(aSource.mStatementOwner)
   {
+    NS_PRECONDITION(mStatementOwner, "Must have a statement owner!");
   }
   StatementData()
   {
   }
 
   /**
    * Return the sqlite statement, fetching it from the storage statement.  In
    * the case of AsyncStatements this may actually create the statement 
@@ -100,31 +104,49 @@ public:
   {
     return mStatementOwner->getOwner()->GetNativeConnection();
   }
 
   /**
    * NULLs out our sqlite3_stmt (it is held by the owner) after reseting it and
    * clear all bindings to it.  This is expected to occur on the async thread.
    *
-   * We do not clear mParamsArray out because we only want to release
-   * mParamsArray on the calling thread because of XPCVariant addref/release
-   * thread-safety issues.  The same holds for mStatementOwner which can be
-   * holding such a reference chain as well.
+   * @param aReleaseThread
+   *        The thread that we should release mParamsArray and mStatementOwner
+   *        on.  This may not be the thread we are called on.
    */
-  inline void finalize()
+  inline void finalize(nsIEventTarget *aReleaseThread)
   {
+    NS_PRECONDITION(aReleaseThread, "Must have a non-NULL release thread!");
+    NS_PRECONDITION(mStatementOwner, "Must have a statement owner!");
+#ifdef DEBUG
+    {
+      nsCOMPtr<nsIEventTarget> asyncThread =
+        mStatementOwner->getOwner()->getAsyncExecutionTarget();
+      // It's possible that we are shutting down the async thread, and this
+      // method would return NULL as a result.
+      if (asyncThread) {
+        PRBool onAsyncThread;
+        NS_ASSERTION(NS_SUCCEEDED(asyncThread->IsOnCurrentThread(&onAsyncThread)) && onAsyncThread,
+                     "This should only be running on the async thread!");
+      }
+    }
+#endif
     // In the AsyncStatement case we may never have populated mStatement if the
     // AsyncExecuteStatements got canceled or a failure occurred in constructing
     // the statement.
     if (mStatement) {
       (void)::sqlite3_reset(mStatement);
       (void)::sqlite3_clear_bindings(mStatement);
       mStatement = NULL;
     }
+    (void)NS_ProxyRelease(aReleaseThread, mStatementOwner, PR_TRUE);
+    if (mParamsArray) {
+      (void)NS_ProxyRelease(aReleaseThread, mParamsArray, PR_TRUE);
+    }
   }
 
   /**
    * Indicates if this statement has parameters to be bound before it is
    * executed.
    *
    * @return true if the statement has parameters to bind against, false
    *         otherwise.
--- a/toolkit/crashreporter/CrashSubmit.jsm
+++ b/toolkit/crashreporter/CrashSubmit.jsm
@@ -352,17 +352,17 @@ Submitter.prototype = {
     iframe.style.minWidth = 0;
 
     let self = this;
     function loadHandler() {
       if (iframe.contentWindow.location == "about:blank")
         return;
       iframe.removeEventListener("load", loadHandler, true);
       if (!self.submitForm()) {
-        this.notifyStatus(FAILED);
+        self.notifyStatus(FAILED);
         self.cleanup();
       }
     }
 
     iframe.addEventListener("load", loadHandler, true);
     this.element.appendChild(iframe);
     this.iframe = iframe;
     iframe.webNavigation.loadURI("chrome://global/content/crash-submit-form.xhtml", 0, null, null, null);