content/media/webrtc/LoadMonitor.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:613fb4cc1340
1 /* -*- Mode: C++; tab-width: 50; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef _LOADMONITOR_H_
7 #define _LOADMONITOR_H_
8
9 #include "mozilla/Mutex.h"
10 #include "mozilla/CondVar.h"
11 #include "mozilla/RefPtr.h"
12 #include "mozilla/Atomics.h"
13 #include "nsAutoPtr.h"
14 #include "nsCOMPtr.h"
15 #include "nsIThread.h"
16 #include "nsIObserver.h"
17
18 namespace mozilla {
19 class LoadInfoUpdateRunner;
20 class LoadInfoCollectRunner;
21
22 class LoadNotificationCallback
23 {
24 public:
25 virtual void LoadChanged(float aSystemLoad, float aProcessLoad) = 0;
26 };
27
28 class LoadMonitor MOZ_FINAL : public nsIObserver
29 {
30 public:
31 NS_DECL_THREADSAFE_ISUPPORTS
32 NS_DECL_NSIOBSERVER
33
34 LoadMonitor(int aLoadUpdateInterval);
35 ~LoadMonitor();
36
37 nsresult Init(nsRefPtr<LoadMonitor> &self);
38 void SetLoadChangeCallback(LoadNotificationCallback* aCallback);
39 void Shutdown();
40 float GetSystemLoad();
41 float GetProcessLoad();
42
43 friend class LoadInfoCollectRunner;
44
45 private:
46
47 void SetProcessLoad(float load);
48 void SetSystemLoad(float load);
49 void FireCallbacks();
50
51 int mLoadUpdateInterval;
52 mozilla::Mutex mLock;
53 mozilla::CondVar mCondVar;
54 bool mShutdownPending;
55 nsCOMPtr<nsIThread> mLoadInfoThread;
56 float mSystemLoad;
57 float mProcessLoad;
58 LoadNotificationCallback* mLoadNotificationCallback;
59 };
60
61 } //namespace
62
63 #endif /* _LOADMONITOR_H_ */

mercurial