Bug 793434. r=smaug
authorKyle Huey <khuey@kylehuey.com>
Sat, 22 Sep 2012 12:45:03 -0700
changeset 107823 a1f06437a8d2417df9df99b2ba9e024dd5714553
parent 107822 fcf9991c8d97a18ac3937b9160ece684399bf1bc
child 107824 9d285bedbc1f2ff03db780382ceaf56a7dea3180
push id23510
push userkhuey@mozilla.com
push dateSat, 22 Sep 2012 22:46:15 +0000
treeherdermozilla-central@9d285bedbc1f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs793434
milestone18.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 793434. r=smaug
dom/file/ArchiveEvent.cpp
--- a/dom/file/ArchiveEvent.cpp
+++ b/dom/file/ArchiveEvent.cpp
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ArchiveEvent.h"
 
 #include "nsContentUtils.h"
 #include "nsCExternalHandlerService.h"
+#include "nsProxyRelease.h"
 
 USING_FILE_NAMESPACE
 
 NS_IMPL_THREADSAFE_ISUPPORTS0(ArchiveItem)
 
 ArchiveItem::ArchiveItem()
 {
   MOZ_COUNT_CTOR(ArchiveItem);
@@ -39,24 +40,40 @@ ArchiveItem::SetType(const nsCString& aT
 ArchiveReaderEvent::ArchiveReaderEvent(ArchiveReader* aArchiveReader)
 : mArchiveReader(aArchiveReader)
 {
   MOZ_COUNT_CTOR(ArchiveReaderEvent);
 }
 
 ArchiveReaderEvent::~ArchiveReaderEvent()
 {
+  if (!NS_IsMainThread()) {
+    nsIMIMEService* mimeService;
+    mMimeService.forget(&mimeService);
+
+    if (mimeService) {
+      nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
+      NS_WARN_IF_FALSE(mainThread, "Couldn't get the main thread! Leaking!");
+
+      if (mainThread) {
+        NS_ProxyRelease(mainThread, mimeService);
+      }
+    }
+  }
+
   MOZ_COUNT_DTOR(ArchiveReaderEvent);
 }
 
 // From the filename to the mimetype:
 nsresult
 ArchiveReaderEvent::GetType(nsCString& aExt,
                             nsCString& aMimeType)
 {
+  MOZ_ASSERT(NS_IsMainThread());
+
   nsresult rv;
   
   if (mMimeService.get() == nullptr) {
     mMimeService = do_GetService(NS_MIMESERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   rv = mMimeService->GetTypeFromExtension(aExt, aMimeType);