Skip to content

Commit

Permalink
Backed out changeset 7c07214ac152 (bug 1181479)
Browse files Browse the repository at this point in the history
  • Loading branch information
BruceSunMozilla committed Sep 23, 2015
1 parent 8266b6d commit 5d6ede5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
6 changes: 1 addition & 5 deletions dom/bluetooth/bluedroid/BluetoothGattManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,11 +617,7 @@ BluetoothGattManager::StartLeScan(const nsTArray<nsString>& aServiceUuids,
ENSURE_GATT_INTF_IS_READY_VOID(aRunnable);

nsString appUuidStr;
if (NS_WARN_IF(NS_FAILED(GenerateUuid(appUuidStr))) || appUuidStr.IsEmpty()) {
DispatchReplyError(aRunnable,
NS_LITERAL_STRING("start LE scan failed"));
return;
}
GenerateUuid(appUuidStr);

size_t index = sClients->IndexOf(appUuidStr, 0 /* Start */, UuidComparator());

Expand Down
8 changes: 3 additions & 5 deletions dom/bluetooth/common/BluetoothUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ StringToUuid(const nsAString& aString, BluetoothUuid& aUuid)
memcpy(&aUuid.mUuid[14], &uuid5, sizeof(uint16_t));
}

nsresult
void
GenerateUuid(nsAString &aUuidString)
{
nsresult rv;
nsCOMPtr<nsIUUIDGenerator> uuidGenerator =
do_GetService("@mozilla.org/uuid-generator;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS_VOID(rv);

nsID uuid;
rv = uuidGenerator->GenerateUUIDInPlace(&uuid);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS_VOID(rv);

// Build a string in {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} format
char uuidBuffer[NSID_LENGTH];
Expand All @@ -86,8 +86,6 @@ GenerateUuid(nsAString &aUuidString)

// Remove {} and the null terminator
aUuidString.Assign(Substring(uuidString, 1, NSID_LENGTH - 3));

return NS_OK;
}

void
Expand Down
2 changes: 1 addition & 1 deletion dom/bluetooth/common/BluetoothUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ StringToUuid(const nsAString& aString, BluetoothUuid& aUuid);
*
* @param aUuidString [out] String to store the generated uuid.
*/
nsresult
void
GenerateUuid(nsAString &aUuidString);

//
Expand Down
4 changes: 2 additions & 2 deletions dom/bluetooth/common/webapi/BluetoothGatt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ BluetoothGatt::Connect(ErrorResult& aRv)
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);

if (mAppUuid.IsEmpty()) {
nsresult rv = GenerateUuid(mAppUuid);
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(rv) && !mAppUuid.IsEmpty(),
GenerateUuid(mAppUuid);
BT_ENSURE_TRUE_REJECT(!mAppUuid.IsEmpty(),
promise,
NS_ERROR_DOM_OPERATION_ERR);
RegisterBluetoothSignalHandler(mAppUuid, this);
Expand Down
4 changes: 2 additions & 2 deletions dom/bluetooth/common/webapi/BluetoothGattServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ BluetoothGattServer::Connect(const nsAString& aAddress, ErrorResult& aRv)
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);

if (mAppUuid.IsEmpty()) {
nsresult rv = GenerateUuid(mAppUuid);
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(rv) && !mAppUuid.IsEmpty(),
GenerateUuid(mAppUuid);
BT_ENSURE_TRUE_REJECT(!mAppUuid.IsEmpty(),
promise,
NS_ERROR_DOM_OPERATION_ERR);
RegisterBluetoothSignalHandler(mAppUuid, this);
Expand Down

0 comments on commit 5d6ede5

Please sign in to comment.