author | Aaron Klotz <aklotz@mozilla.com> |
Fri, 16 Mar 2018 12:23:46 -0600 | |
changeset 462245 | 2e74592c8f953de873f5495d2fa9afa9661ac99c |
parent 462244 | a6528c5018d22c41a03fe1353e188ea0f8526d93 |
child 462246 | 3cec10b16594fb2206fe90337077103906720506 |
push id | 9165 |
push user | asasaki@mozilla.com |
push date | Thu, 26 Apr 2018 21:04:54 +0000 |
treeherder | mozilla-beta@064c3804de2e [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | eeejay |
bugs | 1446280 |
milestone | 61.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
|
--- a/accessible/windows/msaa/Platform.cpp +++ b/accessible/windows/msaa/Platform.cpp @@ -275,16 +275,18 @@ GetInstantiatorExecutable(const DWORD aP if (NS_FAILED(rv)) { return false; } file.forget(aOutClientExe); return NS_SUCCEEDED(rv); } +#if defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) + /** * Appends version information in the format "|a.b.c.d". * If there is no version information, we append nothing. */ static void AppendVersionInfo(nsIFile* aClientExe, nsAString& aStrToAppend) { MOZ_ASSERT(!NS_IsMainThread()); @@ -328,75 +330,92 @@ AppendVersionInfo(nsIFile* aClientExe, n aStrToAppend.AppendInt(minor); aStrToAppend.Append(dot); aStrToAppend.AppendInt(patch); aStrToAppend.Append(dot); aStrToAppend.AppendInt(build); } static void -AccumulateInstantiatorTelemetry(nsIFile* aClientExe, const nsAString& aValue) +AccumulateInstantiatorTelemetry(const nsAString& aValue) { MOZ_ASSERT(NS_IsMainThread()); if (!aValue.IsEmpty()) { #if defined(MOZ_TELEMETRY_REPORTING) Telemetry::ScalarSet(Telemetry::ScalarID::A11Y_INSTANTIATORS, aValue); #endif // defined(MOZ_TELEMETRY_REPORTING) +#if defined(MOZ_CRASHREPORTER) CrashReporter:: AnnotateCrashReport(NS_LITERAL_CSTRING("AccessibilityClient"), NS_ConvertUTF16toUTF8(aValue)); +#endif // defined(MOZ_CRASHREPORTER) } } static void GatherInstantiatorTelemetry(nsIFile* aClientExe) { MOZ_ASSERT(!NS_IsMainThread()); nsString value; nsresult rv = aClientExe->GetLeafName(value); if (NS_SUCCEEDED(rv)) { AppendVersionInfo(aClientExe, value); } - nsCOMPtr<nsIFile> ref(aClientExe); nsCOMPtr<nsIRunnable> runnable( NS_NewRunnableFunction("a11y::AccumulateInstantiatorTelemetry", - [ref, value]() -> void { - AccumulateInstantiatorTelemetry(ref, value); + [value]() -> void { + AccumulateInstantiatorTelemetry(value); })); // Now that we've (possibly) obtained version info, send the resulting // string back to the main thread to accumulate in telemetry. NS_DispatchToMainThread(runnable); } +#endif // defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) + void a11y::SetInstantiator(const uint32_t aPid) { nsCOMPtr<nsIFile> clientExe; if (!GetInstantiatorExecutable(aPid, getter_AddRefs(clientExe))) { -#if defined(MOZ_TELEMETRY_REPORTING) - AccumulateInstantiatorTelemetry(nullptr, NS_LITERAL_STRING("(Failed to retrieve client image name)")); -#endif // defined(MOZ_TELEMETRY_REPORTING) +#if defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) + AccumulateInstantiatorTelemetry(NS_LITERAL_STRING("(Failed to retrieve client image name)")); +#endif // defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) return; } + // Only record the instantiator if it is the first instantiator, or if it does + // not match the previous one. Some blocked clients are repeatedly requesting + // a11y over and over so we don't want to be spawning countless telemetry + // threads. + if (gInstantiator) { + bool equal; + nsresult rv = gInstantiator->Equals(clientExe, &equal); + if (NS_SUCCEEDED(rv) && equal) { + return; + } + } + gInstantiator = clientExe; +#if defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) nsCOMPtr<nsIRunnable> runnable( NS_NewRunnableFunction("a11y::GatherInstantiatorTelemetry", [clientExe]() -> void { GatherInstantiatorTelemetry(clientExe); })); nsCOMPtr<nsIThread> telemetryThread; - NS_NewThread(getter_AddRefs(telemetryThread), runnable); + NS_NewNamedThread("a11y telemetry", getter_AddRefs(telemetryThread), runnable); +#endif // defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) } bool a11y::GetInstantiator(nsIFile** aOutInstantiator) { if (!gInstantiator) { return false; }