mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 429592 part A - allow AnnotateCrashReport to be called from off the main thread in the chrome process, r=ted
--HG-- extra : rebase_source : b2aa9c90368ec702d6c8eaa295cbdd45f2596e6e
This commit is contained in:
parent
e07982855b
commit
a8f9aab7bc
@ -206,6 +206,7 @@ static const int kAvailableVirtualMemoryParameterLen =
|
||||
sizeof(kAvailableVirtualMemoryParameter)-1;
|
||||
|
||||
// this holds additional data sent via the API
|
||||
static Mutex* crashReporterAPILock;
|
||||
static AnnotationTable* crashReporterAPIData_Hash;
|
||||
static nsCString* crashReporterAPIData = nsnull;
|
||||
static nsCString* notesField = nsnull;
|
||||
@ -618,6 +619,9 @@ nsresult SetExceptionHandler(nsILocalFile* aXREDirectory,
|
||||
crashReporterAPIData = new nsCString();
|
||||
NS_ENSURE_TRUE(crashReporterAPIData, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ASSERTION(!crashReporterAPILock, "Shouldn't have a lock yet");
|
||||
crashReporterAPILock = new Mutex("crashReporterAPILock");
|
||||
|
||||
crashReporterAPIData_Hash =
|
||||
new nsDataHashtable<nsCStringHashKey,nsCString>();
|
||||
NS_ENSURE_TRUE(crashReporterAPIData_Hash, NS_ERROR_OUT_OF_MEMORY);
|
||||
@ -1038,20 +1042,17 @@ nsresult UnsetExceptionHandler()
|
||||
|
||||
// do this here in the unlikely case that we succeeded in allocating
|
||||
// our strings but failed to allocate gExceptionHandler.
|
||||
if (crashReporterAPIData_Hash) {
|
||||
delete crashReporterAPIData_Hash;
|
||||
crashReporterAPIData_Hash = nsnull;
|
||||
}
|
||||
delete crashReporterAPIData_Hash;
|
||||
crashReporterAPIData_Hash = nsnull;
|
||||
|
||||
if (crashReporterAPIData) {
|
||||
delete crashReporterAPIData;
|
||||
crashReporterAPIData = nsnull;
|
||||
}
|
||||
delete crashReporterAPILock;
|
||||
crashReporterAPILock = nsnull;
|
||||
|
||||
if (notesField) {
|
||||
delete notesField;
|
||||
notesField = nsnull;
|
||||
}
|
||||
delete crashReporterAPIData;
|
||||
crashReporterAPIData = nsnull;
|
||||
|
||||
delete notesField;
|
||||
notesField = nsnull;
|
||||
|
||||
if (crashReporterPath) {
|
||||
NS_Free(crashReporterPath);
|
||||
@ -1180,6 +1181,10 @@ nsresult AnnotateCrashReport(const nsACString& key, const nsACString& data)
|
||||
return rv;
|
||||
|
||||
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(key, data));
|
||||
@ -1190,6 +1195,8 @@ nsresult AnnotateCrashReport(const nsACString& key, const nsACString& data)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MutexAutoLock lock(*crashReporterAPILock);
|
||||
|
||||
rv = crashReporterAPIData_Hash->Put(key, escapedData);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -64,7 +64,12 @@ bool GetServerURL(nsACString& aServerURL);
|
||||
nsresult SetServerURL(const nsACString& aServerURL);
|
||||
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.
|
||||
nsresult AnnotateCrashReport(const nsACString& key, const nsACString& data);
|
||||
|
||||
nsresult AppendAppNotesToCrashReport(const nsACString& data);
|
||||
nsresult SetRestartArgs(int argc, char** argv);
|
||||
nsresult SetupExtraData(nsILocalFile* aAppDataDirectory,
|
||||
|
Loading…
Reference in New Issue
Block a user