Back to index

lightning-sunbird  0.9+nobinonly
nsWindowCollector.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* vim:set ts=2 sw=2 sts=2 et cindent: */
00003 /* ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is the Metrics extension.
00017  *
00018  * The Initial Developer of the Original Code is Google Inc.
00019  * Portions created by the Initial Developer are Copyright (C) 2006
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *  Brian Ryner <bryner@brianryner.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #ifndef nsWindowCollector_h_
00040 #define nsWindowCollector_h_
00041 
00042 #include "nsIMetricsCollector.h"
00043 #include "nsIObserver.h"
00044 #include "nsTArray.h"
00045 #include "nsCOMPtr.h"
00046 
00047 class nsIDOMWindow;
00048 class nsITimer;
00049 
00050 // This file defines the window collector class, which monitors window
00051 // creation, opening, closing, and destruction, and records the events into
00052 // the metrics service. This information provides additional context for loads
00053 // into each window.
00054 //
00055 // The window collector also manages the list of assigned window ids, which
00056 // are shared by all interested collectors.
00057 //
00058 // Event descriptions:
00059 //
00060 // <window action="create"/>: logged on new window creation.
00061 // This window can correspond to a toplevel window or to a subframe.
00062 // Attributes:
00063 //   windowid: The id of the new window (uint16)
00064 //   parent: The id of the window's parent (uint16)
00065 //   chrome: Set to true if the window has a chrome docshell (boolean)
00066 //
00067 // <window action="open"/>: logged when window.open() is called.
00068 // This will be logged immediately following <windowcreate/> when a toplevel
00069 // window is opened.  It will never be logged for subframe windows.
00070 // Attributes:
00071 //   windowid: The id of the opened window (uint16)
00072 //   opener: The id of the window's opener (uint16)
00073 //
00074 // <window action="close"/>: logged when a toplevel window is closed.
00075 // Attributes:
00076 //   windowid: The id of the closed window (uint16)
00077 //
00078 // <window action="destroy"/>: logged when a window is destroyed.
00079 // Attributes:
00080 //   windowid: The id of the destroyed window (uint16).
00081 
00082 class nsWindowCollector : public nsIMetricsCollector,
00083                           public nsIObserver
00084 {
00085  public:
00086   NS_DECL_ISUPPORTS
00087   NS_DECL_NSIMETRICSCOLLECTOR
00088   NS_DECL_NSIOBSERVER
00089 
00090   nsWindowCollector();
00091 
00092   // VC6 needs this to be public
00093   void LogWindowOpen(nsITimer *timer, nsISupports *subject);
00094 
00095  private:
00096   ~nsWindowCollector();
00097 
00098   // timer callback
00099   static void WindowOpenCallback(nsITimer *timer, void *closure);
00100 
00101   // timers that we're using for deferred window open events
00102   nsTArray< nsCOMPtr<nsITimer> > mWindowOpenTimers;
00103 };
00104 
00105 #define NS_WINDOWCOLLECTOR_CLASSNAME "Window Collector"
00106 #define NS_WINDOWCOLLECTOR_CID \
00107 { 0x56e37604, 0xd593, 0x47e4, {0x87, 0x1f, 0x76, 0x13, 0x64, 0x8e, 0x74, 0x2b}}
00108 
00109 #endif // nsWindowCollector_h_