Chromium Code Reviews| Index: chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.cc |
| diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.cc |
| index eb88330326103cb61d1658307d5711e18a38ce52..2f2ae6a8d6325e4cb438ff77d85262e807d1ec19 100644 |
| --- a/chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.cc |
| +++ b/chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.cc |
| @@ -16,10 +16,12 @@ namespace { |
| const char kPlatformNotSupported[] = |
| "This operation is not supported on your platform"; |
| -scoped_refptr<device::BluetoothAdapter> GetAdapter(Profile* profile) { |
| +void RunCallbackOnAdapterReady( |
| + const device::BluetoothAdapterFactory::AdapterCallback callback, |
| + Profile* profile) { |
| extensions::ExtensionBluetoothEventRouter* event_router = |
| extensions::BluetoothAPI::Get(profile)->bluetooth_event_router(); |
| - return event_router->GetAdapter(); |
| + event_router->RunCallbackOnAdapterReady(callback); |
| } |
| } // namespace |
| @@ -35,12 +37,15 @@ BluetoothExtensionFunction::~BluetoothExtensionFunction() { |
| } |
| bool BluetoothExtensionFunction::RunImpl() { |
| - scoped_refptr<device::BluetoothAdapter> adapter = GetAdapter(profile()); |
| - if (!adapter) { |
| + bool is_bluetooth_supported = |
| + device::BluetoothAdapterFactory::IsBluetoothSupported(); |
| + RunCallbackOnAdapterReady(base::Bind(&BluetoothExtensionFunction::DoWork, |
|
bryeung
2013/01/08 22:24:27
why do we try this when is_bluetooth_supported ==
youngki
2013/01/09 15:12:03
!! You are right. Done.
|
| + base::Unretained(this)), |
| + profile()); |
| + if (!is_bluetooth_supported) { |
| SetError(kPlatformNotSupported); |
| return false; |
| } |
| - DoWork(adapter); |
| return true; |
| } |