| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/udev_linux/udev_loader.h" | 5 #include "device/udev_linux/udev_loader.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "device/udev_linux/udev0_loader.h" | 8 #include "device/udev_linux/udev0_loader.h" |
| 9 #include "device/udev_linux/udev1_loader.h" | 9 #include "device/udev_linux/udev1_loader.h" |
| 10 | 10 |
| 11 namespace device { | 11 namespace device { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 UdevLoader* g_udev_loader = NULL; | 15 UdevLoader* g_udev_loader = NULL; |
| 16 | 16 |
| 17 } // namespace | 17 } // namespace |
| 18 | 18 |
| 19 // static | 19 // static |
| 20 UdevLoader* UdevLoader::Get() { | 20 UdevLoader* UdevLoader::Get() { |
| 21 if (g_udev_loader) | 21 if (g_udev_loader) |
| 22 return g_udev_loader; | 22 return g_udev_loader; |
| 23 | 23 |
| 24 scoped_ptr<UdevLoader> udev_loader; | 24 scoped_ptr<UdevLoader> udev_loader; |
| 25 // This is an ugly hack to get around the fact that a MSAN build on Precise | 25 // This is an ugly hack to get around the fact that a MSAN build on Precise |
| 26 // will only build an instrumented copy of libudev0 and not libudev1. If one | 26 // will only build an instrumented copy of libudev0 and not libudev1. If one |
| 27 // runs the binary on Trusty, it will end up loading an uninstrumented | 27 // runs the binary on Trusty, it will end up loading an uninstrumented |
| 28 // libudev1 at run time. http://crbug.com/437464 | 28 // libudev1 at run time. http://crbug.com/437464 |
| 29 // TODO(thestig): Remove this after upgrading our MSAN LKGR builders to | 29 // TODO(earthdok): Remove this after upgrading our MSAN LKGR builders to |
| 30 // Trusty. | 30 // Trusty. |
| 31 #if !defined(MEMORY_SANITIZER) | 31 #if !defined(MEMORY_SANITIZER) |
| 32 udev_loader.reset(new Udev1Loader); | 32 udev_loader.reset(new Udev1Loader); |
| 33 if (udev_loader->Init()) { | 33 if (udev_loader->Init()) { |
| 34 g_udev_loader = udev_loader.release(); | 34 g_udev_loader = udev_loader.release(); |
| 35 return g_udev_loader; | 35 return g_udev_loader; |
| 36 } | 36 } |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 udev_loader.reset(new Udev0Loader); | 39 udev_loader.reset(new Udev0Loader); |
| 40 if (udev_loader->Init()) { | 40 if (udev_loader->Init()) { |
| 41 g_udev_loader = udev_loader.release(); | 41 g_udev_loader = udev_loader.release(); |
| 42 return g_udev_loader; | 42 return g_udev_loader; |
| 43 } | 43 } |
| 44 CHECK(false); | 44 CHECK(false); |
| 45 return NULL; | 45 return NULL; |
| 46 } | 46 } |
| 47 | 47 |
| 48 UdevLoader::~UdevLoader() { | 48 UdevLoader::~UdevLoader() { |
| 49 } | 49 } |
| 50 | 50 |
| 51 } // namespace device | 51 } // namespace device |
| OLD | NEW |