|
1 /* -*- Mode: C++; tab-width: 50; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
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 #include "LoadManager.h" |
|
7 #include "LoadManagerFactory.h" |
|
8 #include "MainThreadUtils.h" |
|
9 |
|
10 #include "mozilla/Preferences.h" |
|
11 |
|
12 namespace mozilla { |
|
13 |
|
14 LoadManager* LoadManagerBuild(void) |
|
15 { |
|
16 MOZ_ASSERT(NS_IsMainThread()); |
|
17 |
|
18 #if defined(ANDROID) || defined(LINUX) |
|
19 int loadMeasurementInterval = |
|
20 mozilla::Preferences::GetInt("media.navigator.load_adapt.measure_interval", 1000); |
|
21 int averagingSeconds = |
|
22 mozilla::Preferences::GetInt("media.navigator.load_adapt.avg_seconds", 3); |
|
23 float highLoadThreshold = |
|
24 mozilla::Preferences::GetFloat("media.navigator.load_adapt.high_load", 0.90); |
|
25 float lowLoadThreshold = |
|
26 mozilla::Preferences::GetFloat("media.navigator.load_adapt.low_load", 0.40); |
|
27 |
|
28 return new LoadManager(loadMeasurementInterval, |
|
29 averagingSeconds, |
|
30 highLoadThreshold, |
|
31 lowLoadThreshold); |
|
32 #else |
|
33 // LoadManager not implemented on this platform. |
|
34 return nullptr; |
|
35 #endif |
|
36 } |
|
37 |
|
38 void LoadManagerDestroy(mozilla::LoadManager* aLoadManager) |
|
39 { |
|
40 delete aLoadManager; |
|
41 } |
|
42 |
|
43 }; // namespace |