зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1330184 - Register/unregister the IOInterposeObserver on the main thread, regardless of what thread the profiler is started / stopped on. r=njn
MozReview-Commit-ID: 8Y0rspxBJw3 --HG-- extra : rebase_source : a3fff1f5d94f7071200b7adc7010c11a1198661f extra : source : fd537bffda4b653dc7191434c42d068b1b9c65b8
This commit is contained in:
Родитель
fe9d6d3008
Коммит
1c59e2f54d
|
@ -298,16 +298,32 @@ private:
|
|||
}
|
||||
|
||||
if (mInterposeObserver) {
|
||||
mozilla::IOInterposer::Register(mozilla::IOInterposeObserver::OpAll,
|
||||
mInterposeObserver.get());
|
||||
// We need to register the observer on the main thread, because we want
|
||||
// to observe IO that happens on the main thread.
|
||||
if (NS_IsMainThread()) {
|
||||
IOInterposer::Register(IOInterposeObserver::OpAll, mInterposeObserver);
|
||||
} else {
|
||||
RefPtr<ProfilerIOInterposeObserver> observer = mInterposeObserver;
|
||||
NS_DispatchToMainThread(NS_NewRunnableFunction([=]() {
|
||||
IOInterposer::Register(IOInterposeObserver::OpAll, observer);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~ActivePS()
|
||||
{
|
||||
if (mInterposeObserver) {
|
||||
mozilla::IOInterposer::Unregister(mozilla::IOInterposeObserver::OpAll,
|
||||
mInterposeObserver.get());
|
||||
// We need to unregister the observer on the main thread, because that's
|
||||
// where we've registered it.
|
||||
if (NS_IsMainThread()) {
|
||||
IOInterposer::Unregister(IOInterposeObserver::OpAll, mInterposeObserver);
|
||||
} else {
|
||||
RefPtr<ProfilerIOInterposeObserver> observer = mInterposeObserver;
|
||||
NS_DispatchToMainThread(NS_NewRunnableFunction([=]() {
|
||||
IOInterposer::Unregister(IOInterposeObserver::OpAll, observer);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -450,7 +466,7 @@ private:
|
|||
SamplerThread* const mSamplerThread;
|
||||
|
||||
// The interposer that records main thread I/O.
|
||||
const UniquePtr<mozilla::ProfilerIOInterposeObserver> mInterposeObserver;
|
||||
const RefPtr<mozilla::ProfilerIOInterposeObserver> mInterposeObserver;
|
||||
|
||||
// Is the profiler paused?
|
||||
bool mIsPaused;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#ifdef MOZ_GECKO_PROFILER
|
||||
|
||||
#include "mozilla/IOInterposer.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -17,8 +18,13 @@ namespace mozilla {
|
|||
*/
|
||||
class ProfilerIOInterposeObserver final : public IOInterposeObserver
|
||||
{
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ProfilerIOInterposeObserver)
|
||||
|
||||
public:
|
||||
virtual void Observe(Observation& aObservation);
|
||||
|
||||
protected:
|
||||
virtual ~ProfilerIOInterposeObserver() {}
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
Загрузка…
Ссылка в новой задаче