Bug 770317: Add an xperf probe for XPCOM shutdown event. r=glandium
authorNicolas Chaim Echeverria <necheverria@mozilla.com>
Fri, 20 Jul 2012 13:39:23 -0400
changeset 99931 f0544409e0348ae946e29d66cc741c864ff95dc0
parent 99930 6f770754fa9ec2e45cb72f4e881267adfa3d2aae
child 99932 1898167333102b8d5dcda9b98219e9c60a4e85e3
push id12255
push uservdjeric@mozilla.com
push dateFri, 20 Jul 2012 17:40:24 +0000
treeherdermozilla-inbound@f0544409e034 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs770317
milestone17.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
Bug 770317: Add an xperf probe for XPCOM shutdown event. r=glandium
toolkit/components/startup/mozprofilerprobe.mof
toolkit/components/startup/nsAppStartup.cpp
toolkit/components/startup/nsAppStartup.h
--- a/toolkit/components/startup/mozprofilerprobe.mof
+++ b/toolkit/components/startup/mozprofilerprobe.mof
@@ -14,9 +14,16 @@ class MozillaEventPlacesInit : MozillaPr
 {
 };
 
 [dynamic: ToInstance, Description("Mozilla Event: Session Store Window Restored."): Amended,
  Guid("{917B96B1-ECAD-4DAB-A760-8D49027748AE}"),
  EventType(1)]
 class MozillaEventSessionStoreWindowRestored : MozillaProvider
 {
-};
\ No newline at end of file
+};
+
+[dynamic: ToInstance, Description("Mozilla Event: XPCOM Shutdown."): Amended,
+ Guid("{26D1E091-0AE7-4F49-A554-4214445C505C}"),
+ EventType(1)]
+class MozillaEventSessionStoreWindowRestored : MozillaProvider
+{
+};
--- a/toolkit/components/startup/nsAppStartup.cpp
+++ b/toolkit/components/startup/nsAppStartup.cpp
@@ -86,23 +86,29 @@ static NS_DEFINE_CID(kAppShellCID, NS_AP
 // {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} }
+// {26D1E091-0AE7-4F49-A554-4214445C505C}
+#define NS_XPCOM_SHUTDOWN_EVENT_CID \
+  { 0x26D1E091, 0x0AE7, 0x4F49, \
+  { 0xA5, 0x54, 0x42, 0x14, 0x44, 0x5C, 0x50, 0x5C} }
 
 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);
+static NS_DEFINE_CID(kXPCOMShutdownCID,
+  NS_XPCOM_SHUTDOWN_EVENT_CID);  
 #endif //defined(XP_WIN)
 
 using namespace mozilla;
 
 uint32_t gRestartMode = 0;
 
 class nsAppExitEvent : public nsRunnable {
 private:
@@ -159,16 +165,17 @@ nsAppStartup::Init()
 
   os->AddObserver(this, "quit-application-forced", true);
   os->AddObserver(this, "sessionstore-windows-restored", true);
   os->AddObserver(this, "profile-change-teardown", true);
   os->AddObserver(this, "xul-window-registered", true);
   os->AddObserver(this, "xul-window-destroyed", true);
 
 #if defined(XP_WIN)
+  os->AddObserver(this, "xpcom-shutdown", true);
   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"));
@@ -184,16 +191,23 @@ nsAppStartup::Init()
                      "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'");
+                     
+    mXPCOMShutdownProbe =
+      mProbesManager->
+      GetProbe(kXPCOMShutdownCID,
+               NS_LITERAL_CSTRING("xpcom-shutdown"));
+    NS_WARN_IF_FALSE(mXPCOMShutdownProbe,
+                     "Cannot initialize probe 'xpcom-shutdown'");
 
     rv = mProbesManager->StartSession();
     NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
                      "Cannot initialize system probe manager");
   }
 #endif //defined(XP_WIN)
 
   return NS_OK;
@@ -662,16 +676,20 @@ nsAppStartup::Observe(nsISupports *aSubj
 #if defined(XP_WIN)
     if (mSessionWindowRestoredProbe) {
       mSessionWindowRestoredProbe->Trigger();
     }
   } else if (!strcmp(aTopic, "places-init-complete")) {
     if (mPlacesInitCompleteProbe) {
       mPlacesInitCompleteProbe->Trigger();
     }
+  } else if (!strcmp(aTopic, "xpcom-shutdown")) {
+    if (mXPCOMShutdownProbe) {
+      mXPCOMShutdownProbe->Trigger();
+    }
 #endif //defined(XP_WIN)
   } else {
     NS_ERROR("Unexpected observer topic.");
   }
 
   return NS_OK;
 }
 
--- a/toolkit/components/startup/nsAppStartup.h
+++ b/toolkit/components/startup/nsAppStartup.h
@@ -64,12 +64,13 @@ private:
 
 #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;
+  nsRefPtr<Probe> mXPCOMShutdownProbe;
 #endif
 };
 
 #endif // nsAppStartup_h__