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

Unified Diff: device/bluetooth/bluetooth_local_gatt_descriptor.h

Issue 1898643002: Refactor device::BluetoothGattXXX classes to split into remote/local. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor cleanup Created 4 years, 8 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: device/bluetooth/bluetooth_local_gatt_descriptor.h
diff --git a/device/bluetooth/test/mock_bluetooth_gatt_descriptor.h b/device/bluetooth/bluetooth_local_gatt_descriptor.h
similarity index 13%
copy from device/bluetooth/test/mock_bluetooth_gatt_descriptor.h
copy to device/bluetooth/bluetooth_local_gatt_descriptor.h
index e98a4c80ee88bff2b98bc5c1c61fb2ed53cd3f4a..3ba311d5d3a8846eafffd66ae01e69758a1e2b74 100644
--- a/device/bluetooth/test/mock_bluetooth_gatt_descriptor.h
+++ b/device/bluetooth/bluetooth_local_gatt_descriptor.h
@@ -1,54 +1,66 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
+// Copyright 2016 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 DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_DESCRIPTOR_H_
-#define DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_DESCRIPTOR_H_
+#ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_DESCRIPTOR_H_
+#define DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_DESCRIPTOR_H_
#include <stdint.h>
-
-#include <string>
#include <vector>
-#include "base/callback.h"
#include "base/macros.h"
-#include "device/bluetooth/bluetooth_gatt_characteristic.h"
+#include "device/bluetooth/bluetooth_export.h"
#include "device/bluetooth/bluetooth_gatt_descriptor.h"
+#include "device/bluetooth/bluetooth_local_gatt_characteristic.h"
#include "device/bluetooth/bluetooth_uuid.h"
-#include "testing/gmock/include/gmock/gmock.h"
namespace device {
-class MockBluetoothGattCharacteristic;
-
-class MockBluetoothGattDescriptor : public BluetoothGattDescriptor {
+// BluetoothLocalGattDescriptor represents a local or remote GATT characteristic
scheib 2016/04/20 01:23:30 local only.
rkc 2016/04/20 16:31:53 Done.
+// descriptor. A GATT characteristic descriptor provides further information
+// about a characteristic's value. They can be used to describe the
+// characteristic's features or to control certain behaviors.
+//
+// Note: We use virtual inheritance on the GATT descriptor since it will be
+// inherited by platform specific versions of the GATT descriptor classes also.
+// The platform specific remote GATT descriptor classes will inherit both this
+// class and their GATT descriptor class, hence causing an inheritance diamond.
+class DEVICE_BLUETOOTH_EXPORT BluetoothLocalGattDescriptor
+ : public virtual BluetoothGattDescriptor {
public:
- MockBluetoothGattDescriptor(
- MockBluetoothGattCharacteristic* characteristic,
- const std::string& identifier,
+ // Constructs a BluetoothLocalGattDescriptor that can be associated with a
+ // local
scheib 2016/04/20 01:23:30 wrapping
rkc 2016/04/20 16:31:53 Done.
+ // GATT characteristic when the adapter is in the peripheral role. To
+ // associate the returned descriptor with a characteristic, provide an pointer
scheib 2016/04/20 01:23:30 a pointer ^
rkc 2016/04/20 16:31:53 Done.
+ // to that characteristic instance to the create function.
+ //
+ // This method constructs a characteristic descriptor with UUID |uuid| and the
+ // initial cached value |value|. |value| will be cached and returned for read
+ // requests and automatically modified for write requests by default, unless
+ // an instance of BluetoothRemoteGattService::Delegate has been provided to
+ // the
+ // associated BluetoothRemoteGattService instance, in which case the delegate
+ // will
+ // handle the read and write requests.
+ //
+ // Currently, only custom UUIDs, |kCharacteristicDescriptionUuid|, and
+ // |kCharacteristicPresentationFormat| are supported for locally hosted
+ // descriptors. This method will return NULL if |uuid| is any one of the
+ // unsupported predefined descriptor UUIDs.
+ static BluetoothLocalGattDescriptor* Create(
const BluetoothUUID& uuid,
- bool is_local,
- BluetoothGattCharacteristic::Permissions permissions);
- virtual ~MockBluetoothGattDescriptor();
-
- MOCK_CONST_METHOD0(GetIdentifier, std::string());
- MOCK_CONST_METHOD0(GetUUID, BluetoothUUID());
- MOCK_CONST_METHOD0(IsLocal, bool());
- MOCK_CONST_METHOD0(GetValue, const std::vector<uint8_t>&());
- MOCK_CONST_METHOD0(GetCharacteristic, BluetoothGattCharacteristic*());
- MOCK_CONST_METHOD0(GetPermissions,
- BluetoothGattCharacteristic::Permissions());
- MOCK_METHOD2(ReadRemoteDescriptor,
- void(const ValueCallback&, const ErrorCallback&));
- MOCK_METHOD3(WriteRemoteDescriptor,
- void(const std::vector<uint8_t>&,
- const base::Closure&,
- const ErrorCallback&));
+ const std::vector<uint8_t>& value,
scheib 2016/04/20 01:23:30 Because value can be empty on reads it is valid to
rkc 2016/04/20 16:31:54 Agreed. This parameter is gone in a later patch.
+ BluetoothGattCharacteristic::Permissions permissions,
+ BluetoothLocalGattCharacteristic* characteristic);
+
+ protected:
+ BluetoothLocalGattDescriptor();
+ ~BluetoothLocalGattDescriptor() override;
private:
- DISALLOW_COPY_AND_ASSIGN(MockBluetoothGattDescriptor);
+ DISALLOW_COPY_AND_ASSIGN(BluetoothLocalGattDescriptor);
};
} // namespace device
-#endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_DESCRIPTOR_H_
+#endif // DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_DESCRIPTOR_H_

Powered by Google App Engine
This is Rietveld 408576698