Bug 851046: Patch 8 - Add BluetoothSocket* as an argument of callback functions in BluetoothSocketObserver; r=mrbkap

--HG--
extra : rebase_source : 0c3e6e78f59b83faf7c81892974505caa1b1723a
This commit is contained in:
Eric Chou 2013-04-04 17:25:44 -07:00
Родитель 9b0ac5fced
Коммит f47eb75aaf
8 изменённых файлов: 78 добавлений и 30 удалений

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

@ -673,7 +673,8 @@ BluetoothHfpManager::HandleShutdown()
// Virtual function of class SocketConsumer
void
BluetoothHfpManager::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket,
nsAutoPtr<UnixSocketRawData>& aMessage)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1305,8 +1306,10 @@ BluetoothHfpManager::HandleCallStateChanged(uint32_t aCallIndex,
}
void
BluetoothHfpManager::OnConnectSuccess()
BluetoothHfpManager::OnConnectSuccess(BluetoothSocket* aSocket)
{
MOZ_ASSERT(aSocket == mSocket);
nsCOMPtr<nsITelephonyProvider> provider =
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
NS_ENSURE_TRUE_VOID(provider);
@ -1330,8 +1333,10 @@ BluetoothHfpManager::OnConnectSuccess()
}
void
BluetoothHfpManager::OnConnectError()
BluetoothHfpManager::OnConnectError(BluetoothSocket* aSocket)
{
MOZ_ASSERT(aSocket == mSocket);
// For active connection request, we need to reply the DOMRequest
if (mRunnable) {
BluetoothValue v;
@ -1347,8 +1352,10 @@ BluetoothHfpManager::OnConnectError()
}
void
BluetoothHfpManager::OnDisconnect()
BluetoothHfpManager::OnDisconnect(BluetoothSocket* aSocket)
{
MOZ_ASSERT(aSocket == mSocket);
// When we close a connected socket, then restart listening again and
// notify Settings app.
if (mSocketStatus == SocketConnectionStatus::SOCKET_CONNECTED) {

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

@ -57,10 +57,11 @@ public:
~BluetoothHfpManager();
virtual void ReceiveSocketData(
BluetoothSocket* aSocket,
nsAutoPtr<mozilla::ipc::UnixSocketRawData>& aMessage) MOZ_OVERRIDE;
virtual void OnConnectSuccess() MOZ_OVERRIDE;
virtual void OnConnectError() MOZ_OVERRIDE;
virtual void OnDisconnect() MOZ_OVERRIDE;
virtual void OnConnectSuccess(BluetoothSocket* aSocket) MOZ_OVERRIDE;
virtual void OnConnectError(BluetoothSocket* aSocket) MOZ_OVERRIDE;
virtual void OnDisconnect(BluetoothSocket* aSocket) MOZ_OVERRIDE;
bool Connect(const nsAString& aDeviceObjectPath,
const bool aIsHandsfree,

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

@ -928,7 +928,8 @@ BluetoothOppManager::ClientDataHandler(UnixSocketRawData* aMessage)
// Virtual function of class SocketConsumer
void
BluetoothOppManager::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
BluetoothOppManager::ReceiveSocketData(BluetoothSocket* aSocket,
nsAutoPtr<UnixSocketRawData>& aMessage)
{
if (mLastCommand) {
ClientDataHandler(aMessage);
@ -1302,8 +1303,10 @@ BluetoothOppManager::ReceivingFileConfirmation()
}
void
BluetoothOppManager::OnConnectSuccess()
BluetoothOppManager::OnConnectSuccess(BluetoothSocket* aSocket)
{
MOZ_ASSERT(aSocket == mSocket);
if (mRunnable) {
BluetoothReply* reply = new BluetoothReply(BluetoothReplySuccess(true));
mRunnable->SetReply(reply);
@ -1320,8 +1323,10 @@ BluetoothOppManager::OnConnectSuccess()
}
void
BluetoothOppManager::OnConnectError()
BluetoothOppManager::OnConnectError(BluetoothSocket* aSocket)
{
MOZ_ASSERT(aSocket == mSocket);
if (mRunnable) {
nsString errorStr;
errorStr.AssignLiteral("Failed to connect with a bluetooth opp manager!");
@ -1339,8 +1344,10 @@ BluetoothOppManager::OnConnectError()
}
void
BluetoothOppManager::OnDisconnect()
BluetoothOppManager::OnDisconnect(BluetoothSocket* aSocket)
{
MOZ_ASSERT(aSocket == mSocket);
/**
* It is valid for a bluetooth device which is transfering file via OPP
* closing socket without sending OBEX disconnect request first. So we

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

@ -74,8 +74,13 @@ public:
bool IsTransferring();
// Implement interface BluetoothSocketObserver
void ReceiveSocketData(nsAutoPtr<mozilla::ipc::UnixSocketRawData>& aMessage)
MOZ_OVERRIDE;
void ReceiveSocketData(
BluetoothSocket* aSocket,
nsAutoPtr<mozilla::ipc::UnixSocketRawData>& aMessage) MOZ_OVERRIDE;
virtual void OnConnectSuccess(BluetoothSocket* aSocket) MOZ_OVERRIDE;
virtual void OnConnectError(BluetoothSocket* aSocket) MOZ_OVERRIDE;
virtual void OnDisconnect(BluetoothSocket* aSocket) MOZ_OVERRIDE;
void OnConnectSuccess() MOZ_OVERRIDE;
void OnConnectError() MOZ_OVERRIDE;
void OnDisconnect() MOZ_OVERRIDE;

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

@ -173,7 +173,8 @@ BluetoothScoManager::Get()
// Virtual function of class SocketConsumer
void
BluetoothScoManager::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
BluetoothScoManager::ReceiveSocketData(BluetoothSocket* aSocket,
nsAutoPtr<UnixSocketRawData>& aMessage)
{
// SCO socket do nothing here
MOZ_NOT_REACHED("This should never be called!");
@ -255,8 +256,10 @@ BluetoothScoManager::Disconnect()
}
void
BluetoothScoManager::OnConnectSuccess()
BluetoothScoManager::OnConnectSuccess(BluetoothSocket* aSocket)
{
MOZ_ASSERT(aSocket == mSocket);
nsString address;
mSocket->GetAddress(address);
NotifyAudioManager(address);
@ -265,16 +268,20 @@ BluetoothScoManager::OnConnectSuccess()
}
void
BluetoothScoManager::OnConnectError()
BluetoothScoManager::OnConnectError(BluetoothSocket* aSocket)
{
MOZ_ASSERT(aSocket == mSocket);
mSocket->Disconnect();
mSocketStatus = mSocket->GetConnectionStatus();
Listen();
}
void
BluetoothScoManager::OnDisconnect()
BluetoothScoManager::OnDisconnect(BluetoothSocket* aSocket)
{
MOZ_ASSERT(aSocket == mSocket);
if (mSocketStatus == SocketConnectionStatus::SOCKET_CONNECTED) {
Listen();

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

@ -24,11 +24,11 @@ public:
~BluetoothScoManager();
virtual void ReceiveSocketData(
nsAutoPtr<mozilla::ipc::UnixSocketRawData>& aMessage)
MOZ_OVERRIDE;
virtual void OnConnectSuccess() MOZ_OVERRIDE;
virtual void OnConnectError() MOZ_OVERRIDE;
virtual void OnDisconnect() MOZ_OVERRIDE;
BluetoothSocket* aSocket,
nsAutoPtr<mozilla::ipc::UnixSocketRawData>& aMessage) MOZ_OVERRIDE;
virtual void OnConnectSuccess(BluetoothSocket* aSocket) MOZ_OVERRIDE;
virtual void OnConnectError(BluetoothSocket* aSocket) MOZ_OVERRIDE;
virtual void OnDisconnect(BluetoothSocket* aSocket) MOZ_OVERRIDE;
bool Connect(const nsAString& aDeviceObjectPath);
void Disconnect();

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

@ -69,7 +69,7 @@ BluetoothSocket::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mObserver);
mObserver->ReceiveSocketData(aMessage);
mObserver->ReceiveSocketData(this, aMessage);
}
void
@ -77,7 +77,7 @@ BluetoothSocket::OnConnectSuccess()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mObserver);
mObserver->OnConnectSuccess();
mObserver->OnConnectSuccess(this);
}
void
@ -85,7 +85,7 @@ BluetoothSocket::OnConnectError()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mObserver);
mObserver->OnConnectError();
mObserver->OnConnectError(this);
}
void
@ -93,6 +93,6 @@ BluetoothSocket::OnDisconnect()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mObserver);
mObserver->OnDisconnect();
mObserver->OnDisconnect(this);
}

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

@ -14,13 +14,34 @@ using namespace mozilla::ipc;
BEGIN_BLUETOOTH_NAMESPACE
class BluetoothSocket;
class BluetoothSocketObserver
{
public:
virtual void ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage) = 0;
virtual void OnConnectSuccess() = 0;
virtual void OnConnectError() = 0;
virtual void OnDisconnect() = 0;
virtual void ReceiveSocketData(BluetoothSocket* aSocket,
nsAutoPtr<UnixSocketRawData>& aMessage) = 0;
/**
* A callback function which would be called when a socket connection
* is established successfully. To be more specific, this would be called
* when socket state changes from CONNECTING/LISTENING to CONNECTED.
*/
virtual void OnConnectSuccess(BluetoothSocket* aSocket) = 0;
/**
* A callback function which would be called when BluetoothSocket::Connect()
* fails.
*/
virtual void OnConnectError(BluetoothSocket* aSocket) = 0;
/**
* A callback function which would be called when a socket connection
* is dropped. To be more specific, this would be called when socket state
* changes from CONNECTED/LISTENING to DISCONNECTED.
*/
virtual void OnDisconnect(BluetoothSocket* aSocket) = 0;
};
END_BLUETOOTH_NAMESPACE