Bug 1181479: Sync the coding style; r=jocelyn

This commit is contained in:
Bruce Sun 2015-09-21 14:41:02 +08:00
Родитель e03fb4f7d3
Коммит ecebfa45d5
4 изменённых файлов: 43 добавлений и 39 удалений

Просмотреть файл

@ -947,9 +947,6 @@ public:
(int)aStatus);
MOZ_ASSERT(mClient->mReadRemoteRssiRunnable);
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
// Reject the read remote rssi request
DispatchReplyError(mClient->mReadRemoteRssiRunnable,
NS_LITERAL_STRING("ReadRemoteRssi failed"));
@ -1484,9 +1481,6 @@ public:
BT_WARNING("BluetoothGattServerInterface::RegisterServer failed: %d",
(int)aStatus);
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
// Reject the connect request
if (mServer->mConnectPeripheralRunnable) {
DispatchReplyError(mServer->mConnectPeripheralRunnable,
@ -1528,9 +1522,6 @@ public:
(int)aStatus);
MOZ_ASSERT(mServer->mConnectPeripheralRunnable);
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
DispatchReplyError(mServer->mConnectPeripheralRunnable,
NS_LITERAL_STRING("ConnectPeripheral failed"));
mServer->mConnectPeripheralRunnable = nullptr;
@ -1623,9 +1614,6 @@ public:
(int)aStatus);
MOZ_ASSERT(mServer->mDisconnectPeripheralRunnable);
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
// Reject the disconnect request
DispatchReplyError(mServer->mDisconnectPeripheralRunnable,
NS_LITERAL_STRING("DisconnectPeripheral failed"));
@ -2939,9 +2927,6 @@ BluetoothGattManager::ReadRemoteRssiNotification(int aClientIf,
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
size_t index = sClients->IndexOf(aClientIf, 0 /* Start */,
InterfaceIdComparator());
NS_ENSURE_TRUE_VOID(index != sClients->NoIndex);

Просмотреть файл

@ -66,6 +66,39 @@ BluetoothGattServer::~BluetoothGattServer()
Invalidate();
}
void BluetoothGattServer::HandleServerRegistered(const BluetoothValue& aValue)
{
MOZ_ASSERT(aValue.type() == BluetoothValue::Tuint32_t);
mServerIf = aValue.get_uint32_t();
}
void BluetoothGattServer::HandleServerUnregistered(const BluetoothValue& aValue)
{
mServerIf = 0;
}
void BluetoothGattServer::HandleConnectionStateChanged(
const BluetoothValue& aValue)
{
MOZ_ASSERT(aValue.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
const InfallibleTArray<BluetoothNamedValue>& arr =
aValue.get_ArrayOfBluetoothNamedValue();
MOZ_ASSERT(arr.Length() == 2 &&
arr[0].value().type() == BluetoothValue::Tbool &&
arr[1].value().type() == BluetoothValue::TnsString);
BluetoothStatusChangedEventInit init;
init.mStatus = arr[0].value().get_bool();
init.mAddress = arr[1].value().get_nsString();
nsRefPtr<BluetoothStatusChangedEvent> event =
BluetoothStatusChangedEvent::Constructor(
this, NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID), init);
DispatchTrustedEvent(event);
}
void
BluetoothGattServer::HandleServiceHandleUpdated(const BluetoothValue& aValue)
{
@ -151,28 +184,11 @@ BluetoothGattServer::Notify(const BluetoothSignal& aData)
BluetoothValue v = aData.value();
if (aData.name().EqualsLiteral("ServerRegistered")) {
MOZ_ASSERT(v.type() == BluetoothValue::Tuint32_t);
mServerIf = v.get_uint32_t();
HandleServerRegistered(v);
} else if (aData.name().EqualsLiteral("ServerUnregistered")) {
mServerIf = 0;
HandleServerUnregistered(v);
} else if (aData.name().EqualsLiteral(GATT_CONNECTION_STATE_CHANGED_ID)) {
MOZ_ASSERT(v.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
const InfallibleTArray<BluetoothNamedValue>& arr =
v.get_ArrayOfBluetoothNamedValue();
MOZ_ASSERT(arr.Length() == 2 &&
arr[0].value().type() == BluetoothValue::Tbool &&
arr[1].value().type() == BluetoothValue::TnsString);
BluetoothStatusChangedEventInit init;
init.mStatus = arr[0].value().get_bool();
init.mAddress = arr[1].value().get_nsString();
nsRefPtr<BluetoothStatusChangedEvent> event =
BluetoothStatusChangedEvent::Constructor(
this, NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID), init);
DispatchTrustedEvent(event);
HandleConnectionStateChanged(v);
} else if (aData.name().EqualsLiteral("ServiceHandleUpdated")) {
HandleServiceHandleUpdated(v);
} else if (aData.name().EqualsLiteral("CharacteristicHandleUpdated")) {

Просмотреть файл

@ -102,6 +102,9 @@ private:
friend class AddServiceTask;
friend class RemoveServiceTask;
void HandleServerRegistered(const BluetoothValue& aValue);
void HandleServerUnregistered(const BluetoothValue& aValue);
void HandleConnectionStateChanged(const BluetoothValue& aValue);
void HandleServiceHandleUpdated(const BluetoothValue& aValue);
void HandleCharacteristicHandleUpdated(const BluetoothValue& aValue);
void HandleDescriptorHandleUpdated(const BluetoothValue& aValue);

Просмотреть файл

@ -287,7 +287,7 @@ public:
const BluetoothGattServiceId& aServiceId,
const BluetoothGattId& aCharacteristicId,
const BluetoothGattId& aDescriptorId,
BluetoothReplyRunnable* aRunnable);
BluetoothReplyRunnable* aRunnable) override;
virtual void
GattClientWriteDescriptorValueInternal(
@ -296,19 +296,19 @@ public:
const BluetoothGattId& aCharacteristicId,
const BluetoothGattId& aDescriptorId,
const nsTArray<uint8_t>& aValue,
BluetoothReplyRunnable* aRunnable);
BluetoothReplyRunnable* aRunnable) override;
virtual void
GattServerConnectPeripheralInternal(
const nsAString& aAppUuid,
const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable);
BluetoothReplyRunnable* aRunnable) override;
virtual void
GattServerDisconnectPeripheralInternal(
const nsAString& aAppUuid,
const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable);
BluetoothReplyRunnable* aRunnable) override;
virtual void
UnregisterGattServerInternal(int aServerIf,