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 #endif |
| 12 |
| 13 namespace { |
| 14 |
| 15 static device::PlatformSensorProvider* g_provider_for_testing = nullptr; |
| 16 |
| 17 } // namespace |
| 18 |
| 19 namespace device { |
| 20 |
| 21 // static |
| 22 void PlatformSensorProvider::SetProviderForTesting( |
| 23 PlatformSensorProvider* provider) { |
| 24 g_provider_for_testing = provider; |
| 25 } |
| 26 |
| 27 // static |
| 28 PlatformSensorProvider* PlatformSensorProvider::GetInstance() { |
| 29 if (g_provider_for_testing) |
| 30 return g_provider_for_testing; |
| 31 #if defined(OS_MACOSX) |
| 32 return PlatformSensorProviderMac::GetInstance(); |
| 33 #elif defined(OS_ANDROID) |
| 34 return PlatformSensorProviderAndroid::GetInstance(); |
| 35 #else |
| 36 return nullptr; |
| 37 #endif |
| 38 } |
| 39 |
| 40 } // namespace device |
OLD | NEW |