Index: device/bluetooth/bluetooth_adapter_factory.cc |
diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_adapter_factory.cc b/device/bluetooth/bluetooth_adapter_factory.cc |
similarity index 59% |
rename from chrome/browser/chromeos/bluetooth/bluetooth_adapter_factory.cc |
rename to device/bluetooth/bluetooth_adapter_factory.cc |
index eb626220d779078ac039a8b627d2800bf9d8f730..03d633f47c2d40f63822339d6801bd831c08eee8 100644 |
--- a/chrome/browser/chromeos/bluetooth/bluetooth_adapter_factory.cc |
+++ b/device/bluetooth/bluetooth_adapter_factory.cc |
@@ -1,14 +1,17 @@ |
// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-// |
-// TODO(youngki): Guard the ChromeOS specific part with "#ifdef CHROME_OS" block |
-// once we move this code into common directory. |
+ |
+#include "device/bluetooth/bluetooth_adapter_factory.h" |
#include "base/lazy_instance.h" |
#include "base/memory/ref_counted.h" |
-#include "chrome/browser/chromeos/bluetooth/bluetooth_adapter_chromeos.h" |
-#include "chrome/browser/chromeos/bluetooth/bluetooth_adapter_factory.h" |
+#include "base/memory/weak_ptr.h" |
+#include "device/bluetooth/bluetooth_adapter.h" |
+ |
+#if defined(OS_CHROMEOS) |
+#include "device/bluetooth/bluetooth_adapter_chromeos.h" |
+#endif |
namespace { |
@@ -16,19 +19,22 @@ namespace { |
// if nobody is using it so use a WeakPtr and create the object when needed; |
// since Google C++ Style (and clang's static analyzer) forbids us having |
// exit-time destructors we use a leaky lazy instance for it. |
-base::LazyInstance<base::WeakPtr<chromeos::BluetoothAdapter> >::Leaky |
+base::LazyInstance<base::WeakPtr<device::BluetoothAdapter> >::Leaky |
default_adapter = LAZY_INSTANCE_INITIALIZER; |
} // namespace |
-namespace chromeos { |
+namespace device { |
// static |
scoped_refptr<BluetoothAdapter> BluetoothAdapterFactory::DefaultAdapter() { |
if (!default_adapter.Get().get()) { |
- BluetoothAdapterChromeOs* new_adapter = new BluetoothAdapterChromeOs; |
+#if defined(OS_CHROMEOS) |
+ chromeos::BluetoothAdapterChromeOs* new_adapter = |
+ new chromeos::BluetoothAdapterChromeOs; |
new_adapter->TrackDefaultAdapter(); |
default_adapter.Get() = new_adapter->weak_ptr_factory_.GetWeakPtr(); |
+#endif |
} |
return scoped_refptr<BluetoothAdapter>(default_adapter.Get()); |
@@ -36,9 +42,14 @@ scoped_refptr<BluetoothAdapter> BluetoothAdapterFactory::DefaultAdapter() { |
// static |
BluetoothAdapter* BluetoothAdapterFactory::Create(const std::string& address) { |
- BluetoothAdapterChromeOs* adapter = new BluetoothAdapterChromeOs; |
- adapter->FindAdapter(address); |
+ BluetoothAdapter* adapter = NULL; |
+#if defined(OS_CHROMEOS) |
+ chromeos::BluetoothAdapterChromeOs* adapter_chromeos = |
+ new chromeos::BluetoothAdapterChromeOs; |
+ adapter_chromeos->FindAdapter(address); |
+ adapter = adapter_chromeos; |
+#endif |
return adapter; |
} |
-} // namespace chromeos |
+} // namespace device |