Bug 1039579 - CrashReporterParent::NotifyCrashService must always be on the main thread, r=ted

This commit is contained in:
Benjamin Smedberg 2014-07-18 13:31:21 -04:00
Родитель fb8b8fe840
Коммит b0015d28b5
1 изменённых файлов: 20 добавлений и 1 удалений

Просмотреть файл

@ -11,6 +11,8 @@
#ifdef MOZ_CRASHREPORTER
#include "nsExceptionHandler.h"
#include "nsICrashService.h"
#include "mozilla/SyncRunnable.h"
#include "nsThreadUtils.h"
#endif
using namespace base;
@ -114,6 +116,7 @@ CrashReporterParent::GenerateChildData(const AnnotationTable* processNotes)
type = NS_LITERAL_CSTRING("content");
break;
case GeckoProcessType_Plugin:
case GeckoProcessType_GMPlugin:
type = NS_LITERAL_CSTRING("plugin");
break;
default:
@ -135,14 +138,30 @@ CrashReporterParent::GenerateChildData(const AnnotationTable* processNotes)
if (!ret)
NS_WARNING("problem appending child data to .extra");
NotifyCrashService();
nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
class NotifyOnMainThread : public nsRunnable
{
public:
NotifyOnMainThread(CrashReporterParent* aCR)
: mCR(aCR)
{ }
NS_IMETHOD Run() {
mCR->NotifyCrashService();
return NS_OK;
}
private:
CrashReporterParent* mCR;
};
SyncRunnable::DispatchToThread(mainThread, new NotifyOnMainThread(this));
return ret;
}
void
CrashReporterParent::NotifyCrashService()
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsICrashService> crashService =
do_GetService("@mozilla.org/crashservice;1");
if (!crashService) {