зеркало из https://github.com/mozilla/pjs.git
Bug 696033 - Add xperf probes (sample startup probes); r=glandium
This commit is contained in:
Родитель
26f7112f4e
Коммит
b67df65c58
|
@ -0,0 +1,22 @@
|
|||
#pragma namespace("\\\\.\\root\\wmi")
|
||||
#pragma autorecover
|
||||
|
||||
[dynamic: ToInstance, Description("Mozilla Generic Provider"),
|
||||
Guid("{509962E0-406B-46F4-99BA-5A009F8D2225}")]
|
||||
class MozillaProvider : EventTrace
|
||||
{
|
||||
};
|
||||
|
||||
[dynamic: ToInstance, Description("Mozilla Event: Places Init is complete."): Amended,
|
||||
Guid("{A3DA04E0-57D7-482A-A1C1-61DA5F95BACB}"),
|
||||
EventType(1)]
|
||||
class MozillaEventPlacesInit : MozillaProvider
|
||||
{
|
||||
};
|
||||
|
||||
[dynamic: ToInstance, Description("Mozilla Event: Session Store Window Restored."): Amended,
|
||||
Guid("{917B96B1-ECAD-4DAB-A760-8D49027748AE}"),
|
||||
EventType(1)]
|
||||
class MozillaEventSessionStoreWindowRestored : MozillaProvider
|
||||
{
|
||||
};
|
|
@ -27,6 +27,7 @@
|
|||
* Daniel Brooks <db48x@db48x.net>
|
||||
* Taras Glek <tglek@mozilla.com>
|
||||
* Landry Breuil <landry@openbsd.org>
|
||||
* David Rajchenbach-Teller <dteller@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
|
@ -98,6 +99,38 @@
|
|||
|
||||
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
|
||||
#if defined(XP_WIN)
|
||||
#include "mozilla/perfprobe.h"
|
||||
/**
|
||||
* Events sent to the system for profiling purposes
|
||||
*/
|
||||
//Keep them syncronized with the .mof file
|
||||
|
||||
//Process-wide GUID, used by the OS to differentiate sources
|
||||
// {509962E0-406B-46F4-99BA-5A009F8D2225}
|
||||
//Keep it synchronized with the .mof file
|
||||
#define NS_APPLICATION_TRACING_CID \
|
||||
{ 0x509962E0, 0x406B, 0x46F4, \
|
||||
{ 0x99, 0xBA, 0x5A, 0x00, 0x9F, 0x8D, 0x22, 0x25} }
|
||||
|
||||
//Event-specific GUIDs, used by the OS to differentiate events
|
||||
// {A3DA04E0-57D7-482A-A1C1-61DA5F95BACB}
|
||||
#define NS_PLACES_INIT_COMPLETE_EVENT_CID \
|
||||
{ 0xA3DA04E0, 0x57D7, 0x482A, \
|
||||
{ 0xA1, 0xC1, 0x61, 0xDA, 0x5F, 0x95, 0xBA, 0xCB} }
|
||||
// {917B96B1-ECAD-4DAB-A760-8D49027748AE}
|
||||
#define NS_SESSION_STORE_WINDOW_RESTORED_EVENT_CID \
|
||||
{ 0x917B96B1, 0xECAD, 0x4DAB, \
|
||||
{ 0xA7, 0x60, 0x8D, 0x49, 0x02, 0x77, 0x48, 0xAE} }
|
||||
|
||||
static NS_DEFINE_CID(kApplicationTracingCID,
|
||||
NS_APPLICATION_TRACING_CID);
|
||||
static NS_DEFINE_CID(kPlacesInitCompleteCID,
|
||||
NS_PLACES_INIT_COMPLETE_EVENT_CID);
|
||||
static NS_DEFINE_CID(kSessionStoreWindowRestoredCID,
|
||||
NS_SESSION_STORE_WINDOW_RESTORED_EVENT_CID);
|
||||
#endif //defined(XP_WIN)
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
PRUint32 gRestartMode = 0;
|
||||
|
@ -159,6 +192,39 @@ nsAppStartup::Init()
|
|||
os->AddObserver(this, "xul-window-registered", true);
|
||||
os->AddObserver(this, "xul-window-destroyed", true);
|
||||
|
||||
#if defined(XP_WIN)
|
||||
os->AddObserver(this, "places-init-complete", true);
|
||||
// This last event is only interesting to us for xperf-based measures
|
||||
|
||||
// Initialize interaction with profiler
|
||||
mProbesManager =
|
||||
new ProbeManager(
|
||||
kApplicationTracingCID,
|
||||
NS_LITERAL_CSTRING("Application startup probe"));
|
||||
// Note: The operation is meant mostly for in-house profiling.
|
||||
// Therefore, we do not warn if probes manager cannot be initialized
|
||||
|
||||
if (mProbesManager) {
|
||||
mPlacesInitCompleteProbe =
|
||||
mProbesManager->
|
||||
GetProbe(kPlacesInitCompleteCID,
|
||||
NS_LITERAL_CSTRING("places-init-complete"));
|
||||
NS_WARN_IF_FALSE(mPlacesInitCompleteProbe,
|
||||
"Cannot initialize probe 'places-init-complete'");
|
||||
|
||||
mSessionWindowRestoredProbe =
|
||||
mProbesManager->
|
||||
GetProbe(kSessionStoreWindowRestoredCID,
|
||||
NS_LITERAL_CSTRING("sessionstore-windows-restored"));
|
||||
NS_WARN_IF_FALSE(mSessionWindowRestoredProbe,
|
||||
"Cannot initialize probe 'sessionstore-windows-restored'");
|
||||
|
||||
rv = mProbesManager->StartSession();
|
||||
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
|
||||
"Cannot initialize system probe manager");
|
||||
}
|
||||
#endif //defined(XP_WIN)
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -560,6 +626,15 @@ nsAppStartup::Observe(nsISupports *aSubject,
|
|||
ExitLastWindowClosingSurvivalArea();
|
||||
} else if (!strcmp(aTopic, "sessionstore-windows-restored")) {
|
||||
StartupTimeline::Record(StartupTimeline::SESSION_RESTORED);
|
||||
#if defined(XP_WIN)
|
||||
if (mSessionWindowRestoredProbe) {
|
||||
mSessionWindowRestoredProbe->Trigger();
|
||||
}
|
||||
} else if (!strcmp(aTopic, "places-init-complete")) {
|
||||
if (mPlacesInitCompleteProbe) {
|
||||
mPlacesInitCompleteProbe->Trigger();
|
||||
}
|
||||
#endif //defined(XP_WIN)
|
||||
} else {
|
||||
NS_ERROR("Unexpected observer topic.");
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Benjamin Smedberg <bsmedberg@covad.net>
|
||||
* David Rajchenbach-Teller <dteller@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
|
@ -48,6 +49,13 @@
|
|||
#include "nsINativeAppSupport.h"
|
||||
#include "nsIAppShell.h"
|
||||
|
||||
#if defined(XP_WIN)
|
||||
//XPerf-backed probes
|
||||
#include "mozilla/perfprobe.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#endif //defined(XP_WIN)
|
||||
|
||||
|
||||
struct PLEvent;
|
||||
|
||||
// {7DD4D320-C84B-4624-8D45-7BB9B2356977}
|
||||
|
@ -85,6 +93,15 @@ private:
|
|||
bool mAttemptingQuit; // Quit(eAttemptQuit) still trying
|
||||
bool mRestart; // Quit(eRestart)
|
||||
bool mInterrupted; // Was startup interrupted by an interactive prompt?
|
||||
|
||||
#if defined(XP_WIN)
|
||||
//Interaction with OS-provided profiling probes
|
||||
typedef mozilla::probes::ProbeManager ProbeManager;
|
||||
typedef mozilla::probes::Probe Probe;
|
||||
nsRefPtr<ProbeManager> mProbesManager;
|
||||
nsRefPtr<Probe> mPlacesInitCompleteProbe;
|
||||
nsRefPtr<Probe> mSessionWindowRestoredProbe;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // nsAppStartup_h__
|
||||
|
|
Загрузка…
Ссылка в новой задаче