Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Unified Diff: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_connection.h

Issue 349433002: chrome.bluetoothLowEnergy: Introduce connect and disconnect methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_connection.h
diff --git a/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_connection.h b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_connection.h
new file mode 100644
index 0000000000000000000000000000000000000000..cf66f748215ed542e4f227e10df1be7ffb47b916
--- /dev/null
+++ b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_connection.h
@@ -0,0 +1,48 @@
+// Copyright 2014 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.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_CONNECTION_H_
+#define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_CONNECTION_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "device/bluetooth/bluetooth_gatt_connection.h"
+#include "extensions/browser/api/api_resource.h"
+#include "extensions/browser/api/api_resource_manager.h"
+
+namespace extensions {
+
+// An ApiResource wrapper for a device::BluetoothGattConnection.
+class BluetoothLowEnergyConnection : public ApiResource {
+ public:
+ explicit BluetoothLowEnergyConnection(
+ const std::string& owner_extension_id,
+ scoped_ptr<device::BluetoothGattConnection> connection);
+ virtual ~BluetoothLowEnergyConnection();
+
+ // Returns a pointer to the underlying connection object.
+ device::BluetoothGattConnection* GetConnection() const;
+
+ // ApiResource override.
+ virtual bool IsPersistent() const OVERRIDE;
+
+ // This resource should be managed on the UI thread.
+ static const content::BrowserThread::ID kThreadId =
+ content::BrowserThread::UI;
+
+ private:
+ friend class ApiResourceManager<BluetoothLowEnergyConnection>;
+ static const char* service_name() {
+ return "BluetoothLowEnergyConnectionManager";
+ }
+
+ // The connection is owned by this instance and will automatically disconnect
+ // when deleted.
+ scoped_ptr<device::BluetoothGattConnection> connection_;
+
+ DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyConnection);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_CONNECTION_H_

Powered by Google App Engine
This is Rietveld 408576698