Backed out changeset 71d0b47d316a (bug 1220121)

This commit is contained in:
Carsten "Tomcat" Book 2015-11-12 11:48:56 +01:00
parent 38af5c8f0b
commit fb53c2e843
10 changed files with 82 additions and 73 deletions

View File

@ -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());

View File

@ -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

View File

@ -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!");

View File

@ -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

View File

@ -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

View File

@ -1748,13 +1748,6 @@ BluetoothAdapter::SendFile(const nsAString& aDeviceAddress,
RefPtr<BluetoothVoidReplyRunnable> 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<BluetoothVoidReplyRunnable> 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<BluetoothVoidReplyRunnable> 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();
}

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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