Bug 853358 - Add plugin profiling support. r=ehsan,bsmedberg
This commit is contained in:
@@ -38,7 +38,9 @@
|
||||
#include "PluginHangUIParent.h"
|
||||
#include "mozilla/widget/AudioSession.h"
|
||||
#endif
|
||||
#include "GeckoProfiler.h"
|
||||
#include "nsIProfileSaveEvent.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsIObserverService.h"
|
||||
|
||||
using base::KillProcess;
|
||||
|
||||
@@ -138,12 +140,16 @@ PluginModuleParent::PluginModuleParent(const char* aFilePath)
|
||||
Preferences::RegisterCallback(TimeoutChanged, kHangUITimeoutPref, this);
|
||||
Preferences::RegisterCallback(TimeoutChanged, kHangUIMinDisplayPref, this);
|
||||
#endif
|
||||
|
||||
InitPluginProfiling();
|
||||
}
|
||||
|
||||
PluginModuleParent::~PluginModuleParent()
|
||||
{
|
||||
NS_ASSERTION(OkToCleanup(), "unsafe destruction");
|
||||
|
||||
ShutdownPluginProfiling();
|
||||
|
||||
if (!mShutdown) {
|
||||
NS_WARNING("Plugin host deleted the module without shutting down.");
|
||||
NPError err;
|
||||
@@ -1710,3 +1716,56 @@ PluginModuleParent::OnCrash(DWORD processID)
|
||||
}
|
||||
|
||||
#endif // MOZ_CRASHREPORTER_INJECTOR
|
||||
|
||||
class PluginProfilerObserver MOZ_FINAL : public nsIObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
explicit PluginProfilerObserver(PluginModuleParent* pmp)
|
||||
: mPmp(pmp)
|
||||
{}
|
||||
|
||||
private:
|
||||
PluginModuleParent* mPmp;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS2(PluginProfilerObserver, nsIObserver, nsISupportsWeakReference)
|
||||
|
||||
NS_IMETHODIMP
|
||||
PluginProfilerObserver::Observe(nsISupports *aSubject,
|
||||
const char *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
nsCOMPtr<nsIProfileSaveEvent> pse = do_QueryInterface(aSubject);
|
||||
if (pse) {
|
||||
nsCString result;
|
||||
bool success = mPmp->CallGeckoGetProfile(&result);
|
||||
if (success && !result.IsEmpty()) {
|
||||
pse->AddSubProfile(result.get());
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
PluginModuleParent::InitPluginProfiling()
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
|
||||
if (observerService) {
|
||||
mProfilerObserver = new PluginProfilerObserver(this);
|
||||
observerService->AddObserver(mProfilerObserver, "profiler-subprocess", false);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PluginModuleParent::ShutdownPluginProfiling()
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
|
||||
if (observerService) {
|
||||
observerService->RemoveObserver(mProfilerObserver, "profiler-subprocess");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user