| |
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 _LOADMANAGER_H_ |
| |
7 #define _LOADMANAGER_H_ |
| |
8 |
| |
9 #include "LoadMonitor.h" |
| |
10 #include "webrtc/common_types.h" |
| |
11 #include "webrtc/video_engine/include/vie_base.h" |
| |
12 #include "mozilla/TimeStamp.h" |
| |
13 #include "nsTArray.h" |
| |
14 |
| |
15 extern PRLogModuleInfo *gLoadManagerLog; |
| |
16 |
| |
17 namespace mozilla { |
| |
18 |
| |
19 class LoadManager : public LoadNotificationCallback, |
| |
20 public webrtc::CPULoadStateCallbackInvoker, |
| |
21 public webrtc::CpuOveruseObserver |
| |
22 { |
| |
23 public: |
| |
24 LoadManager(int aLoadMeasurementInterval, |
| |
25 int aAveragingMeasurements, |
| |
26 float aHighLoadThreshold, |
| |
27 float aLowLoadThreshold); |
| |
28 ~LoadManager(); |
| |
29 |
| |
30 // LoadNotificationCallback interface |
| |
31 virtual void LoadChanged(float aSystemLoad, float aProcessLoad) MOZ_OVERRIDE; |
| |
32 // CpuOveruseObserver interface |
| |
33 // Called as soon as an overuse is detected. |
| |
34 virtual void OveruseDetected() MOZ_OVERRIDE; |
| |
35 // Called periodically when the system is not overused any longer. |
| |
36 virtual void NormalUsage() MOZ_OVERRIDE; |
| |
37 // CPULoadStateCallbackInvoker interface |
| |
38 virtual void AddObserver(webrtc::CPULoadStateObserver * aObserver) MOZ_OVERRIDE; |
| |
39 virtual void RemoveObserver(webrtc::CPULoadStateObserver * aObserver) MOZ_OVERRIDE; |
| |
40 |
| |
41 private: |
| |
42 void LoadHasChanged(); |
| |
43 |
| |
44 nsRefPtr<LoadMonitor> mLoadMonitor; |
| |
45 float mLoadSum; |
| |
46 int mLoadSumMeasurements; |
| |
47 // Set when overuse was signaled to us, and hasn't been un-signaled yet. |
| |
48 bool mOveruseActive; |
| |
49 // Load measurement settings |
| |
50 int mLoadMeasurementInterval; |
| |
51 int mAveragingMeasurements; |
| |
52 float mHighLoadThreshold; |
| |
53 float mLowLoadThreshold; |
| |
54 |
| |
55 webrtc::CPULoadState mCurrentState; |
| |
56 |
| |
57 nsTArray<webrtc::CPULoadStateObserver*> mObservers; |
| |
58 }; |
| |
59 |
| |
60 } //namespace |
| |
61 |
| |
62 #endif /* _LOADMANAGER_H_ */ |