16d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 26d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 36d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// found in the LICENSE file. 46d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 51320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#ifndef EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_CONNECTION_H_ 61320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#define EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_CONNECTION_H_ 76d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 86d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 96d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "device/bluetooth/bluetooth_gatt_connection.h" 106d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "extensions/browser/api/api_resource.h" 116d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "extensions/browser/api/api_resource_manager.h" 126d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 136d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)namespace extensions { 146d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 156d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// An ApiResource wrapper for a device::BluetoothGattConnection. 166d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)class BluetoothLowEnergyConnection : public ApiResource { 176d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) public: 186d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) explicit BluetoothLowEnergyConnection( 196d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) bool persistent, 206d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) const std::string& owner_extension_id, 216d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) scoped_ptr<device::BluetoothGattConnection> connection); 226d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) virtual ~BluetoothLowEnergyConnection(); 236d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 246d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) // Returns a pointer to the underlying connection object. 256d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) device::BluetoothGattConnection* GetConnection() const; 266d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 276d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) // ApiResource override. 286d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) virtual bool IsPersistent() const OVERRIDE; 296d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 306d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) // This resource should be managed on the UI thread. 316d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) static const content::BrowserThread::ID kThreadId = 326d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) content::BrowserThread::UI; 336d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 346d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) private: 356d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) friend class ApiResourceManager<BluetoothLowEnergyConnection>; 366d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) static const char* service_name() { 376d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) return "BluetoothLowEnergyConnectionManager"; 386d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } 396d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 406d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) // True, if this resource should be persistent. 416d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) bool persistent_; 426d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 436d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) // The connection is owned by this instance and will automatically disconnect 446d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) // when deleted. 456d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) scoped_ptr<device::BluetoothGattConnection> connection_; 466d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 476d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyConnection); 486d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)}; 496d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 506d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)} // namespace extensions 516d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 521320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#endif // EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_CONNECTION_H_ 53