OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "device/generic_sensor/platform_sensor_provider.h" | |
6 | |
7 #if defined(OS_MACOSX) | |
8 #include "device/generic_sensor/platform_sensor_provider_mac.h" | |
9 #elif defined(OS_ANDROID) | |
10 #include "device/generic_sensor/platform_sensor_provider_android.h" | |
11 #elif defined(OS_WIN) | |
12 #include "device/generic_sensor/platform_sensor_provider_win.h" | |
13 #elif defined(OS_LINUX) && defined(USE_UDEV) | |
14 #include "device/generic_sensor/platform_sensor_provider_linux.h" | |
15 #endif | |
16 | |
17 namespace { | |
18 | |
19 static device::PlatformSensorProvider* g_provider_for_testing = nullptr; | |
20 | |
21 } // namespace | |
22 | |
23 namespace device { | |
24 | |
25 // static | |
26 void PlatformSensorProvider::SetProviderForTesting( | |
27 PlatformSensorProvider* provider) { | |
28 g_provider_for_testing = provider; | |
29 } | |
30 | |
31 // static | |
32 PlatformSensorProvider* PlatformSensorProvider::GetInstance() { | |
33 if (g_provider_for_testing) | |
34 return g_provider_for_testing; | |
35 #if defined(OS_MACOSX) | |
36 return PlatformSensorProviderMac::GetInstance(); | |
37 #elif defined(OS_ANDROID) | |
38 return PlatformSensorProviderAndroid::GetInstance(); | |
39 #elif defined(OS_WIN) | |
40 return PlatformSensorProviderWin::GetInstance(); | |
41 #elif defined(OS_LINUX) && defined(USE_UDEV) | |
42 return PlatformSensorProviderLinux::GetInstance(); | |
43 #else | |
44 return nullptr; | |
45 #endif | |
46 } | |
47 | |
48 } // namespace device | |
OLD | NEW |