sbTimingService.h
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
27 #ifndef __SBTIMINGSERVICE_H__
28 #define __SBTIMINGSERVICE_H__
29 
30 #include <sbITimingService.h>
31 
32 #include <nsIFile.h>
33 #include <nsIObserver.h>
34 #include <nsIGenericFactory.h>
35 
36 #include <nsAutoLock.h>
37 #include <nsCOMPtr.h>
38 #include <nsInterfaceHashtable.h>
39 #include <nsStringGlue.h>
40 #include <nsTHashtable.h>
41 
42 class sbTimingService;
44 
46 {
47  friend class sbTimingService;
48 
49 public:
52 
55 
56  nsresult Init(const nsAString &aTimerName);
57 
58 protected:
59  PRLock * mTimerLock;
60 
61  nsString mTimerName;
62 
66 };
67 
69  public nsIObserver
70 {
71 public:
72 
74  NS_DECL_NSIOBSERVER
75  NS_DECL_SBITIMINGSERVICE
76 
79 
80  static NS_METHOD RegisterSelf(nsIComponentManager* aCompMgr,
81  nsIFile* aPath,
82  const char* aLoaderStr,
83  const char* aType,
84  const nsModuleComponentInfo *aInfo);
85 
86  NS_METHOD Init();
87 
88  nsresult FormatResultsToString(nsACString &aOutput);
89 
90 private:
91  PRLock * mLoggingLock;
92  PRBool mLoggingEnabled;
93  nsCOMPtr<nsIFile> mLogFile;
94 
95  // Supplementary lock is required to ensure that a timer of the same name
96  // as another does not get inserted while the first time is in process of
97  // insertion.
98  PRLock *mTimersLock;
99 
100  nsInterfaceHashtableMT<nsStringHashKey, sbITimingServiceTimer> mTimers;
101 
102  // Supplementary lock is required to ensure that the count doesn't change
103  // between the time we look it up and the time we insert an entry.
104  PRLock *mResultsLock;
105 
106  nsInterfaceHashtableMT<nsUint32HashKey, sbITimingServiceTimer> mResults;
107 };
108 
109 #endif /* __SBTIMINGSERVICE_H__ */
110 
_updateCookies aPath
NS_DECL_ISUPPORTS NS_DECL_NSIOBSERVER NS_DECL_SBITIMINGSERVICE sbTimingService()
nsresult FormatResultsToString(nsACString &aOutput)
static NS_METHOD RegisterSelf(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *aLoaderStr, const char *aType, const nsModuleComponentInfo *aInfo)
An interface for running simple, time based, profiling.
NS_DECL_ISUPPORTS NS_DECL_SBITIMINGSERVICETIMER
nsresult Init(const nsAString &aTimerName)