mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 717951 - Allow AppendAppNotesToCrashReport to be called from off the main thread in the chrome process. r=ted
This commit is contained in:
parent
3cc60bc3bc
commit
68cc9e12bb
@ -216,6 +216,7 @@ static const int kOOMAllocationSizeParameterLen =
|
||||
|
||||
// this holds additional data sent via the API
|
||||
static Mutex* crashReporterAPILock;
|
||||
static Mutex* notesFieldLock;
|
||||
static AnnotationTable* crashReporterAPIData_Hash;
|
||||
static nsCString* crashReporterAPIData = nsnull;
|
||||
static nsCString* notesField = nsnull;
|
||||
@ -657,6 +658,8 @@ nsresult SetExceptionHandler(nsILocalFile* aXREDirectory,
|
||||
|
||||
NS_ASSERTION(!crashReporterAPILock, "Shouldn't have a lock yet");
|
||||
crashReporterAPILock = new Mutex("crashReporterAPILock");
|
||||
NS_ASSERTION(!notesFieldLock, "Shouldn't have a lock yet");
|
||||
notesFieldLock = new Mutex("notesFieldLock");
|
||||
|
||||
crashReporterAPIData_Hash =
|
||||
new nsDataHashtable<nsCStringHashKey,nsCString>();
|
||||
@ -1086,6 +1089,9 @@ nsresult UnsetExceptionHandler()
|
||||
delete crashReporterAPILock;
|
||||
crashReporterAPILock = nsnull;
|
||||
|
||||
delete notesFieldLock;
|
||||
notesFieldLock = nsnull;
|
||||
|
||||
delete crashReporterAPIData;
|
||||
crashReporterAPIData = nsnull;
|
||||
|
||||
@ -1255,6 +1261,10 @@ nsresult AppendAppNotesToCrashReport(const nsACString& data)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
if (XRE_GetProcessType() != GeckoProcessType_Default) {
|
||||
if (!NS_IsMainThread()) {
|
||||
NS_ERROR("Cannot call AnnotateCrashReport in child processes from non-main thread.");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
PCrashReporterChild* reporter = CrashReporterChild::GetCrashReporter();
|
||||
if (!reporter) {
|
||||
EnqueueDelayedNote(new DelayedNote(data));
|
||||
@ -1274,6 +1284,8 @@ nsresult AppendAppNotesToCrashReport(const nsACString& data)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MutexAutoLock lock(*notesFieldLock);
|
||||
|
||||
notesField->Append(data);
|
||||
return AnnotateCrashReport(NS_LITERAL_CSTRING("Notes"), *notesField);
|
||||
}
|
||||
|
@ -66,11 +66,12 @@ bool GetMinidumpPath(nsAString& aPath);
|
||||
nsresult SetMinidumpPath(const nsAString& aPath);
|
||||
|
||||
|
||||
// AnnotateCrashReport may be called from any thread in a chrome process,
|
||||
// but may only be called from the main thread in a content process.
|
||||
// AnnotateCrashReport and AppendAppNotesToCrashReport may be called from any
|
||||
// thread in a chrome process, but may only be called from the main thread in
|
||||
// a content process.
|
||||
nsresult AnnotateCrashReport(const nsACString& key, const nsACString& data);
|
||||
|
||||
nsresult AppendAppNotesToCrashReport(const nsACString& data);
|
||||
|
||||
nsresult SetRestartArgs(int argc, char** argv);
|
||||
nsresult SetupExtraData(nsILocalFile* aAppDataDirectory,
|
||||
const nsACString& aBuildID);
|
||||
|
Loading…
Reference in New Issue
Block a user