| OLD | NEW | 
|   1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |   1 // Copyright (c) 2012 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 "extensions/browser/api/bluetooth/bluetooth_extension_function.h" |   5 #include "extensions/browser/api/bluetooth/bluetooth_extension_function.h" | 
|   6  |   6  | 
|   7 #include "base/memory/ref_counted.h" |   7 #include "base/memory/ref_counted.h" | 
|   8 #include "content/public/browser/browser_thread.h" |   8 #include "content/public/browser/browser_thread.h" | 
|   9 #include "device/bluetooth/bluetooth_adapter.h" |   9 #include "device/bluetooth/bluetooth_adapter.h" | 
|  10 #include "device/bluetooth/bluetooth_adapter_factory.h" |  10 #include "device/bluetooth/bluetooth_adapter_factory.h" | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
|  31  |  31  | 
|  32 void GetAdapter(const device::BluetoothAdapterFactory::AdapterCallback callback, |  32 void GetAdapter(const device::BluetoothAdapterFactory::AdapterCallback callback, | 
|  33                 content::BrowserContext* context) { |  33                 content::BrowserContext* context) { | 
|  34   DCHECK_CURRENTLY_ON(BrowserThread::UI); |  34   DCHECK_CURRENTLY_ON(BrowserThread::UI); | 
|  35   GetEventRouter(context)->GetAdapter(callback); |  35   GetEventRouter(context)->GetAdapter(callback); | 
|  36 } |  36 } | 
|  37  |  37  | 
|  38 }  // namespace |  38 }  // namespace | 
|  39  |  39  | 
|  40 namespace extensions { |  40 namespace extensions { | 
|  41 namespace core_api { |  41 namespace api { | 
|  42  |  42  | 
|  43 BluetoothExtensionFunction::BluetoothExtensionFunction() { |  43 BluetoothExtensionFunction::BluetoothExtensionFunction() { | 
|  44 } |  44 } | 
|  45  |  45  | 
|  46 BluetoothExtensionFunction::~BluetoothExtensionFunction() { |  46 BluetoothExtensionFunction::~BluetoothExtensionFunction() { | 
|  47 } |  47 } | 
|  48  |  48  | 
|  49 bool BluetoothExtensionFunction::RunAsync() { |  49 bool BluetoothExtensionFunction::RunAsync() { | 
|  50   DCHECK_CURRENTLY_ON(BrowserThread::UI); |  50   DCHECK_CURRENTLY_ON(BrowserThread::UI); | 
|  51  |  51  | 
|  52   if (!IsBluetoothSupported(browser_context())) { |  52   if (!IsBluetoothSupported(browser_context())) { | 
|  53     SetError(kPlatformNotSupported); |  53     SetError(kPlatformNotSupported); | 
|  54     return false; |  54     return false; | 
|  55   } |  55   } | 
|  56   GetAdapter(base::Bind(&BluetoothExtensionFunction::RunOnAdapterReady, this), |  56   GetAdapter(base::Bind(&BluetoothExtensionFunction::RunOnAdapterReady, this), | 
|  57              browser_context()); |  57              browser_context()); | 
|  58  |  58  | 
|  59   return true; |  59   return true; | 
|  60 } |  60 } | 
|  61  |  61  | 
|  62 void BluetoothExtensionFunction::RunOnAdapterReady( |  62 void BluetoothExtensionFunction::RunOnAdapterReady( | 
|  63     scoped_refptr<device::BluetoothAdapter> adapter) { |  63     scoped_refptr<device::BluetoothAdapter> adapter) { | 
|  64   DCHECK_CURRENTLY_ON(BrowserThread::UI); |  64   DCHECK_CURRENTLY_ON(BrowserThread::UI); | 
|  65   DoWork(adapter); |  65   DoWork(adapter); | 
|  66 } |  66 } | 
|  67  |  67  | 
|  68 }  // namespace core_api |  68 }  // namespace api | 
|  69 }  // namespace extensions |  69 }  // namespace extensions | 
| OLD | NEW |