From fb53c2e84393f231a58273835ab56bc5eac2e314 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Thu, 12 Nov 2015 11:48:56 +0100 Subject: [PATCH] Backed out changeset 71d0b47d316a (bug 1220121) --- .../bluedroid/BluetoothServiceBluedroid.cpp | 28 +++++++++++++----- .../bluedroid/BluetoothServiceBluedroid.h | 8 ++--- dom/bluetooth/bluez/BluetoothDBusService.cpp | 29 +++++++++++++------ dom/bluetooth/bluez/BluetoothDBusService.h | 8 ++--- dom/bluetooth/common/BluetoothService.h | 8 ++--- .../common/webapi/BluetoothAdapter.cpp | 29 +++---------------- dom/bluetooth/ipc/BluetoothParent.cpp | 8 ++--- .../ipc/BluetoothServiceChildProcess.cpp | 21 +++++++++----- .../ipc/BluetoothServiceChildProcess.h | 8 ++--- dom/bluetooth/ipc/PBluetooth.ipdl | 8 ++--- 10 files changed, 82 insertions(+), 73 deletions(-) diff --git a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp index 91cf0550b94..167ab1a1986 100644 --- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp +++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp @@ -1526,20 +1526,27 @@ BluetoothServiceBluedroid::Disconnect( } void -BluetoothServiceBluedroid::SendFile(const BluetoothAddress& aDeviceAddress, +BluetoothServiceBluedroid::SendFile(const nsAString& aDeviceAddress, BlobParent* aBlobParent, BlobChild* aBlobChild, BluetoothReplyRunnable* aRunnable) { MOZ_ASSERT(NS_IsMainThread()); + BluetoothAddress deviceAddress; + nsresult rv = StringToAddress(aDeviceAddress, deviceAddress); + if (NS_FAILED(rv)) { + DispatchReplyError(aRunnable, STATUS_PARM_INVALID); + return; + } + // Currently we only support one device sending one file at a time, // so we don't need aDeviceAddress here because the target device // has been determined when calling 'Connect()'. Nevertheless, keep // it for future use. BluetoothOppManager* opp = BluetoothOppManager::Get(); - if (!opp || !opp->SendFile(aDeviceAddress, aBlobParent)) { + if (!opp || !opp->SendFile(deviceAddress, aBlobParent)) { DispatchReplyError(aRunnable, NS_LITERAL_STRING("SendFile failed")); return; } @@ -1548,19 +1555,26 @@ BluetoothServiceBluedroid::SendFile(const BluetoothAddress& aDeviceAddress, } void -BluetoothServiceBluedroid::SendFile(const BluetoothAddress& aDeviceAddress, +BluetoothServiceBluedroid::SendFile(const nsAString& aDeviceAddress, Blob* aBlob, BluetoothReplyRunnable* aRunnable) { MOZ_ASSERT(NS_IsMainThread()); + BluetoothAddress deviceAddress; + nsresult rv = StringToAddress(aDeviceAddress, deviceAddress); + if (NS_FAILED(rv)) { + DispatchReplyError(aRunnable, STATUS_PARM_INVALID); + return; + } + // Currently we only support one device sending one file at a time, // so we don't need aDeviceAddress here because the target device // has been determined when calling 'Connect()'. Nevertheless, keep // it for future use. BluetoothOppManager* opp = BluetoothOppManager::Get(); - if (!opp || !opp->SendFile(aDeviceAddress, aBlob)) { + if (!opp || !opp->SendFile(deviceAddress, aBlob)) { DispatchReplyError(aRunnable, NS_LITERAL_STRING("SendFile failed")); return; } @@ -1569,8 +1583,8 @@ BluetoothServiceBluedroid::SendFile(const BluetoothAddress& aDeviceAddress, } void -BluetoothServiceBluedroid::StopSendingFile( - const BluetoothAddress& aDeviceAddress, BluetoothReplyRunnable* aRunnable) +BluetoothServiceBluedroid::StopSendingFile(const nsAString& aDeviceAddress, + BluetoothReplyRunnable* aRunnable) { MOZ_ASSERT(NS_IsMainThread()); @@ -1591,7 +1605,7 @@ BluetoothServiceBluedroid::StopSendingFile( void BluetoothServiceBluedroid::ConfirmReceivingFile( - const BluetoothAddress& aDeviceAddress, bool aConfirm, + const nsAString& aDeviceAddress, bool aConfirm, BluetoothReplyRunnable* aRunnable) { MOZ_ASSERT(NS_IsMainThread()); diff --git a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h index 5a09e23f3e9..566ec422058 100644 --- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h +++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h @@ -121,22 +121,22 @@ public: BluetoothReplyRunnable* aRunnable); virtual void - SendFile(const BluetoothAddress& aDeviceAddress, + SendFile(const nsAString& aDeviceAddress, BlobParent* aBlobParent, BlobChild* aBlobChild, BluetoothReplyRunnable* aRunnable); virtual void - SendFile(const BluetoothAddress& aDeviceAddress, + SendFile(const nsAString& aDeviceAddress, Blob* aBlob, BluetoothReplyRunnable* aRunnable); virtual void - StopSendingFile(const BluetoothAddress& aDeviceAddress, + StopSendingFile(const nsAString& aDeviceAddress, BluetoothReplyRunnable* aRunnable); virtual void - ConfirmReceivingFile(const BluetoothAddress& aDeviceAddress, bool aConfirm, + ConfirmReceivingFile(const nsAString& aDeviceAddress, bool aConfirm, BluetoothReplyRunnable* aRunnable); virtual void diff --git a/dom/bluetooth/bluez/BluetoothDBusService.cpp b/dom/bluetooth/bluez/BluetoothDBusService.cpp index 2c0d72fc9fa..e789aa4e698 100644 --- a/dom/bluetooth/bluez/BluetoothDBusService.cpp +++ b/dom/bluetooth/bluez/BluetoothDBusService.cpp @@ -3778,20 +3778,26 @@ BluetoothDBusService::UpdateSdpRecords(const BluetoothAddress& aDeviceAddress, } void -BluetoothDBusService::SendFile(const BluetoothAddress& aDeviceAddress, +BluetoothDBusService::SendFile(const nsAString& aDeviceAddress, BlobParent* aBlobParent, BlobChild* aBlobChild, BluetoothReplyRunnable* aRunnable) { MOZ_ASSERT(NS_IsMainThread()); + BluetoothAddress deviceAddress; + if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) { + DispatchReplyError(aRunnable, STATUS_PARM_INVALID); + return; + } + // Currently we only support one device sending one file at a time, // so we don't need aDeviceAddress here because the target device // has been determined when calling 'Connect()'. Nevertheless, keep // it for future use. BluetoothOppManager* opp = BluetoothOppManager::Get(); nsAutoString errorStr; - if (!opp || !opp->SendFile(aDeviceAddress, aBlobParent)) { + if (!opp || !opp->SendFile(deviceAddress, aBlobParent)) { errorStr.AssignLiteral("Calling SendFile() failed"); } @@ -3799,19 +3805,25 @@ BluetoothDBusService::SendFile(const BluetoothAddress& aDeviceAddress, } void -BluetoothDBusService::SendFile(const BluetoothAddress& aDeviceAddress, +BluetoothDBusService::SendFile(const nsAString& aDeviceAddress, Blob* aBlob, BluetoothReplyRunnable* aRunnable) { MOZ_ASSERT(NS_IsMainThread()); + BluetoothAddress deviceAddress; + if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) { + DispatchReplyError(aRunnable, STATUS_PARM_INVALID); + return; + } + // Currently we only support one device sending one file at a time, // so we don't need aDeviceAddress here because the target device // has been determined when calling 'Connect()'. Nevertheless, keep // it for future use. BluetoothOppManager* opp = BluetoothOppManager::Get(); nsAutoString errorStr; - if (!opp || !opp->SendFile(aDeviceAddress, aBlob)) { + if (!opp || !opp->SendFile(deviceAddress, aBlob)) { errorStr.AssignLiteral("Calling SendFile() failed"); } @@ -3819,7 +3831,7 @@ BluetoothDBusService::SendFile(const BluetoothAddress& aDeviceAddress, } void -BluetoothDBusService::StopSendingFile(const BluetoothAddress& aDeviceAddress, +BluetoothDBusService::StopSendingFile(const nsAString& aDeviceAddress, BluetoothReplyRunnable* aRunnable) { MOZ_ASSERT(NS_IsMainThread()); @@ -3838,10 +3850,9 @@ BluetoothDBusService::StopSendingFile(const BluetoothAddress& aDeviceAddress, } void -BluetoothDBusService::ConfirmReceivingFile( - const BluetoothAddress& aDeviceAddress, - bool aConfirm, - BluetoothReplyRunnable* aRunnable) +BluetoothDBusService::ConfirmReceivingFile(const nsAString& aDeviceAddress, + bool aConfirm, + BluetoothReplyRunnable* aRunnable) { MOZ_ASSERT(NS_IsMainThread(), "Must be called from main thread!"); diff --git a/dom/bluetooth/bluez/BluetoothDBusService.h b/dom/bluetooth/bluez/BluetoothDBusService.h index 8d12a37f7d8..a47f2762399 100644 --- a/dom/bluetooth/bluez/BluetoothDBusService.h +++ b/dom/bluetooth/bluez/BluetoothDBusService.h @@ -133,22 +133,22 @@ public: BluetoothReplyRunnable* aRunnable) override; virtual void - SendFile(const BluetoothAddress& aDeviceAddress, + SendFile(const nsAString& aDeviceAddress, BlobParent* aBlobParent, BlobChild* aBlobChild, BluetoothReplyRunnable* aRunnable) override; virtual void - SendFile(const BluetoothAddress& aDeviceAddress, + SendFile(const nsAString& aDeviceAddress, Blob* aBlob, BluetoothReplyRunnable* aRunnable) override; virtual void - StopSendingFile(const BluetoothAddress& aDeviceAddress, + StopSendingFile(const nsAString& aDeviceAddress, BluetoothReplyRunnable* aRunnable) override; virtual void - ConfirmReceivingFile(const BluetoothAddress& aDeviceAddress, bool aConfirm, + ConfirmReceivingFile(const nsAString& aDeviceAddress, bool aConfirm, BluetoothReplyRunnable* aRunnable) override; virtual void diff --git a/dom/bluetooth/common/BluetoothService.h b/dom/bluetooth/common/BluetoothService.h index d5838c3ce6d..6533df0399f 100644 --- a/dom/bluetooth/common/BluetoothService.h +++ b/dom/bluetooth/common/BluetoothService.h @@ -286,22 +286,22 @@ public: BluetoothReplyRunnable* aRunnable) = 0; virtual void - SendFile(const BluetoothAddress& aDeviceAddress, + SendFile(const nsAString& aDeviceAddress, BlobParent* aBlobParent, BlobChild* aBlobChild, BluetoothReplyRunnable* aRunnable) = 0; virtual void - SendFile(const BluetoothAddress& aDeviceAddress, + SendFile(const nsAString& aDeviceAddress, Blob* aBlob, BluetoothReplyRunnable* aRunnable) = 0; virtual void - StopSendingFile(const BluetoothAddress& aDeviceAddress, + StopSendingFile(const nsAString& aDeviceAddress, BluetoothReplyRunnable* aRunnable) = 0; virtual void - ConfirmReceivingFile(const BluetoothAddress& aDeviceAddress, bool aConfirm, + ConfirmReceivingFile(const nsAString& aDeviceAddress, bool aConfirm, BluetoothReplyRunnable* aRunnable) = 0; virtual void diff --git a/dom/bluetooth/common/webapi/BluetoothAdapter.cpp b/dom/bluetooth/common/webapi/BluetoothAdapter.cpp index a2eaecaa0f2..a82221e2911 100644 --- a/dom/bluetooth/common/webapi/BluetoothAdapter.cpp +++ b/dom/bluetooth/common/webapi/BluetoothAdapter.cpp @@ -1748,13 +1748,6 @@ BluetoothAdapter::SendFile(const nsAString& aDeviceAddress, RefPtr results = new BluetoothVoidReplyRunnable(request); - BluetoothAddress deviceAddress; - auto rv = StringToAddress(aDeviceAddress, deviceAddress); - if (NS_FAILED(rv)) { - aRv.Throw(rv); - return nullptr; - } - BluetoothService* bs = BluetoothService::Get(); if (!bs) { aRv.Throw(NS_ERROR_FAILURE); @@ -1763,7 +1756,7 @@ BluetoothAdapter::SendFile(const nsAString& aDeviceAddress, if (XRE_IsParentProcess()) { // In-process transfer - bs->SendFile(deviceAddress, &aBlob, results); + bs->SendFile(aDeviceAddress, &aBlob, results); } else { ContentChild *cc = ContentChild::GetSingleton(); if (!cc) { @@ -1777,7 +1770,7 @@ BluetoothAdapter::SendFile(const nsAString& aDeviceAddress, return nullptr; } - bs->SendFile(deviceAddress, nullptr, actor, results); + bs->SendFile(aDeviceAddress, nullptr, actor, results); } return request.forget(); @@ -1797,19 +1790,12 @@ BluetoothAdapter::StopSendingFile( RefPtr results = new BluetoothVoidReplyRunnable(request); - BluetoothAddress deviceAddress; - auto rv = StringToAddress(aDeviceAddress, deviceAddress); - if (NS_FAILED(rv)) { - aRv.Throw(rv); - return nullptr; - } - BluetoothService* bs = BluetoothService::Get(); if (!bs) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; } - bs->StopSendingFile(deviceAddress, results); + bs->StopSendingFile(aDeviceAddress, results); return request.forget(); } @@ -1828,19 +1814,12 @@ BluetoothAdapter::ConfirmReceivingFile(const nsAString& aDeviceAddress, RefPtr results = new BluetoothVoidReplyRunnable(request); - BluetoothAddress deviceAddress; - auto rv = StringToAddress(aDeviceAddress, deviceAddress); - if (NS_FAILED(rv)) { - aRv.Throw(rv); - return nullptr; - } - BluetoothService* bs = BluetoothService::Get(); if (!bs) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; } - bs->ConfirmReceivingFile(deviceAddress, aConfirmation, results); + bs->ConfirmReceivingFile(aDeviceAddress, aConfirmation, results); return request.forget(); } diff --git a/dom/bluetooth/ipc/BluetoothParent.cpp b/dom/bluetooth/ipc/BluetoothParent.cpp index d4a700c3f9f..73c4b6a49ce 100644 --- a/dom/bluetooth/ipc/BluetoothParent.cpp +++ b/dom/bluetooth/ipc/BluetoothParent.cpp @@ -680,7 +680,7 @@ BluetoothRequestParent::DoRequest(const SendFileRequest& aRequest) MOZ_ASSERT(mService); MOZ_ASSERT(mRequestType == Request::TSendFileRequest); - mService->SendFile(aRequest.address(), + mService->SendFile(aRequest.devicePath(), (BlobParent*)aRequest.blobParent(), (BlobChild*)aRequest.blobChild(), mReplyRunnable.get()); @@ -694,7 +694,7 @@ BluetoothRequestParent::DoRequest(const StopSendingFileRequest& aRequest) MOZ_ASSERT(mService); MOZ_ASSERT(mRequestType == Request::TStopSendingFileRequest); - mService->StopSendingFile(aRequest.address(), + mService->StopSendingFile(aRequest.devicePath(), mReplyRunnable.get()); return true; @@ -706,7 +706,7 @@ BluetoothRequestParent::DoRequest(const ConfirmReceivingFileRequest& aRequest) MOZ_ASSERT(mService); MOZ_ASSERT(mRequestType == Request::TConfirmReceivingFileRequest); - mService->ConfirmReceivingFile(aRequest.address(), + mService->ConfirmReceivingFile(aRequest.devicePath(), true, mReplyRunnable.get()); return true; @@ -718,7 +718,7 @@ BluetoothRequestParent::DoRequest(const DenyReceivingFileRequest& aRequest) MOZ_ASSERT(mService); MOZ_ASSERT(mRequestType == Request::TDenyReceivingFileRequest); - mService->ConfirmReceivingFile(aRequest.address(), + mService->ConfirmReceivingFile(aRequest.devicePath(), false, mReplyRunnable.get()); return true; diff --git a/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp b/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp index c5f3cd35041..95c73272da2 100644 --- a/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp +++ b/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp @@ -286,17 +286,18 @@ BluetoothServiceChildProcess::Disconnect( void BluetoothServiceChildProcess::SendFile( - const BluetoothAddress& aDeviceAddress, + const nsAString& aDeviceAddress, BlobParent* aBlobParent, BlobChild* aBlobChild, BluetoothReplyRunnable* aRunnable) { - SendRequest(aRunnable, SendFileRequest(aDeviceAddress, nullptr, aBlobChild)); + SendRequest(aRunnable, + SendFileRequest(nsString(aDeviceAddress), nullptr, aBlobChild)); } void BluetoothServiceChildProcess::SendFile( - const BluetoothAddress& aDeviceAddress, + const nsAString& aDeviceAddress, Blob* aBlobChild, BluetoothReplyRunnable* aRunnable) { @@ -306,23 +307,27 @@ BluetoothServiceChildProcess::SendFile( void BluetoothServiceChildProcess::StopSendingFile( - const BluetoothAddress& aDeviceAddress, + const nsAString& aDeviceAddress, BluetoothReplyRunnable* aRunnable) { - SendRequest(aRunnable, StopSendingFileRequest(aDeviceAddress)); + SendRequest(aRunnable, + StopSendingFileRequest(nsString(aDeviceAddress))); } void BluetoothServiceChildProcess::ConfirmReceivingFile( - const BluetoothAddress& aDeviceAddress, bool aConfirm, + const nsAString& aDeviceAddress, + bool aConfirm, BluetoothReplyRunnable* aRunnable) { if(aConfirm) { - SendRequest(aRunnable, ConfirmReceivingFileRequest(aDeviceAddress)); + SendRequest(aRunnable, + ConfirmReceivingFileRequest(nsString(aDeviceAddress))); return; } - SendRequest(aRunnable, DenyReceivingFileRequest(aDeviceAddress)); + SendRequest(aRunnable, + DenyReceivingFileRequest(nsString(aDeviceAddress))); } void diff --git a/dom/bluetooth/ipc/BluetoothServiceChildProcess.h b/dom/bluetooth/ipc/BluetoothServiceChildProcess.h index 47630f462de..49da5e3dd7c 100644 --- a/dom/bluetooth/ipc/BluetoothServiceChildProcess.h +++ b/dom/bluetooth/ipc/BluetoothServiceChildProcess.h @@ -130,22 +130,22 @@ public: BluetoothReplyRunnable* aRunnable) override; virtual void - SendFile(const BluetoothAddress& aDeviceAddress, + SendFile(const nsAString& aDeviceAddress, BlobParent* aBlobParent, BlobChild* aBlobChild, BluetoothReplyRunnable* aRunnable) override; virtual void - SendFile(const BluetoothAddress& aDeviceAddress, + SendFile(const nsAString& aDeviceAddress, Blob* aBlob, BluetoothReplyRunnable* aRunnable) override; virtual void - StopSendingFile(const BluetoothAddress& aDeviceAddress, + StopSendingFile(const nsAString& aDeviceAddress, BluetoothReplyRunnable* aRunnable) override; virtual void - ConfirmReceivingFile(const BluetoothAddress& aDeviceAddress, + ConfirmReceivingFile(const nsAString& aDeviceAddress, bool aConfirm, BluetoothReplyRunnable* aRunnable) override; diff --git a/dom/bluetooth/ipc/PBluetooth.ipdl b/dom/bluetooth/ipc/PBluetooth.ipdl index 7db36752193..318ee5daebe 100644 --- a/dom/bluetooth/ipc/PBluetooth.ipdl +++ b/dom/bluetooth/ipc/PBluetooth.ipdl @@ -145,23 +145,23 @@ struct DisconnectRequest struct SendFileRequest { - BluetoothAddress address; + nsString devicePath; PBlob blob; }; struct StopSendingFileRequest { - BluetoothAddress address; + nsString devicePath; }; struct ConfirmReceivingFileRequest { - BluetoothAddress address; + nsString devicePath; }; struct DenyReceivingFileRequest { - BluetoothAddress address; + nsString devicePath; }; struct ConnectScoRequest