summaryrefslogtreecommitdiffstats
path: root/device
diff options
context:
space:
mode:
authoryoungki@chromium.org <youngki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-25 21:31:20 +0000
committeryoungki@chromium.org <youngki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-25 21:31:20 +0000
commit91406e5818c8a2751de17061e8f421eb2b30d5f3 (patch)
tree0a5a6c681c4426a456e31efb71e8d6b3929c5651 /device
parent649aa10f202f310604abd1170b452d6c099a4260 (diff)
downloadchromium_src-91406e5818c8a2751de17061e8f421eb2b30d5f3.zip
chromium_src-91406e5818c8a2751de17061e8f421eb2b30d5f3.tar.gz
chromium_src-91406e5818c8a2751de17061e8f421eb2b30d5f3.tar.bz2
Made BluetoothAdapterFactory return BluetoothAdapterWin on Windows platform. Currently BluetoothAdapterWin is a class with empty implementation.
Also I renamed bluetooth_apitest_chromeos.cc as bluetooth_apitest.cc so that this test runs on all platforms. The test is already platform-independent. I think it's safe to integrate BluetoothAdapterWin into BluetoothAdapterFactory as long as we run bluetooth_apitest.cc on Windows platform. Also BluetoothAdapterWin is basically a no-op class anyways. BUG= Review URL: https://chromiumcodereview.appspot.com/11267002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164181 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device')
-rw-r--r--device/bluetooth/bluetooth_adapter_factory.cc7
-rw-r--r--device/bluetooth/bluetooth_adapter_win.cc4
-rw-r--r--device/bluetooth/bluetooth_adapter_win.h10
3 files changed, 20 insertions, 1 deletions
diff --git a/device/bluetooth/bluetooth_adapter_factory.cc b/device/bluetooth/bluetooth_adapter_factory.cc
index 03d633f..689edaf 100644
--- a/device/bluetooth/bluetooth_adapter_factory.cc
+++ b/device/bluetooth/bluetooth_adapter_factory.cc
@@ -11,6 +11,8 @@
#if defined(OS_CHROMEOS)
#include "device/bluetooth/bluetooth_adapter_chromeos.h"
+#elif defined(OS_WIN)
+#include "device/bluetooth/bluetooth_adapter_win.h"
#endif
namespace {
@@ -34,6 +36,9 @@ scoped_refptr<BluetoothAdapter> BluetoothAdapterFactory::DefaultAdapter() {
new chromeos::BluetoothAdapterChromeOs;
new_adapter->TrackDefaultAdapter();
default_adapter.Get() = new_adapter->weak_ptr_factory_.GetWeakPtr();
+#elif defined(OS_WIN)
+ BluetoothAdapterWin* new_adapter = new BluetoothAdapterWin;
+ default_adapter.Get() = new_adapter->weak_ptr_factory_.GetWeakPtr();
#endif
}
@@ -48,6 +53,8 @@ BluetoothAdapter* BluetoothAdapterFactory::Create(const std::string& address) {
new chromeos::BluetoothAdapterChromeOs;
adapter_chromeos->FindAdapter(address);
adapter = adapter_chromeos;
+#elif defined(OS_WIN)
+ adapter = new BluetoothAdapterWin;
#endif
return adapter;
}
diff --git a/device/bluetooth/bluetooth_adapter_win.cc b/device/bluetooth/bluetooth_adapter_win.cc
index c248c9a..97eca65 100644
--- a/device/bluetooth/bluetooth_adapter_win.cc
+++ b/device/bluetooth/bluetooth_adapter_win.cc
@@ -11,7 +11,9 @@
namespace device {
-BluetoothAdapterWin::BluetoothAdapterWin() : BluetoothAdapter() {
+BluetoothAdapterWin::BluetoothAdapterWin()
+ : BluetoothAdapter(),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
}
BluetoothAdapterWin::~BluetoothAdapterWin() {
diff --git a/device/bluetooth/bluetooth_adapter_win.h b/device/bluetooth/bluetooth_adapter_win.h
index 8df27a2..de76b18 100644
--- a/device/bluetooth/bluetooth_adapter_win.h
+++ b/device/bluetooth/bluetooth_adapter_win.h
@@ -7,10 +7,12 @@
#include <string>
+#include "base/memory/weak_ptr.h"
#include "device/bluetooth/bluetooth_adapter.h"
namespace device {
+class BluetoothAdapterFactory;
class BluetoothDevice;
class BluetoothAdapterWin : public BluetoothAdapter {
@@ -37,8 +39,16 @@ class BluetoothAdapterWin : public BluetoothAdapter {
const ErrorCallback& error_callback) OVERRIDE;
private:
+ friend class device::BluetoothAdapterFactory;
+
BluetoothAdapterWin();
virtual ~BluetoothAdapterWin();
+
+ // NOTE: This should remain the last member so it'll be destroyed and
+ // invalidate its weak pointers before any other members are destroyed.
+ base::WeakPtrFactory<BluetoothAdapterWin> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterWin);
};
} // namespace device