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