diff --git a/dom/nfc/gonk/NfcService.cpp b/dom/nfc/gonk/NfcService.cpp index e40336b6d3c..824bf9479cf 100644 --- a/dom/nfc/gonk/NfcService.cpp +++ b/dom/nfc/gonk/NfcService.cpp @@ -371,6 +371,24 @@ NfcService::ReceiveSocketData(nsAutoPtr& aData) mThread->Dispatch(runnable, nsIEventTarget::DISPATCH_NORMAL); } +void +NfcService::OnConnectSuccess(enum SocketType aSocketType) +{ + MOZ_ASSERT(NS_IsMainThread()); +} + +void +NfcService::OnConnectError(enum SocketType aSocketType) +{ + MOZ_ASSERT(NS_IsMainThread()); +} + +void +NfcService::OnDisconnect(enum SocketType aSocketType) +{ + MOZ_ASSERT(NS_IsMainThread()); +} + NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(NfcService, NfcService::FactoryCreate) diff --git a/dom/nfc/gonk/NfcService.h b/dom/nfc/gonk/NfcService.h index 71e359aefc4..7129110d061 100644 --- a/dom/nfc/gonk/NfcService.h +++ b/dom/nfc/gonk/NfcService.h @@ -29,8 +29,12 @@ public: void DispatchNfcEvent(const mozilla::dom::NfcEventOptions& aOptions); - virtual void - ReceiveSocketData(nsAutoPtr& aData) MOZ_OVERRIDE; + virtual void ReceiveSocketData( + nsAutoPtr& aData) MOZ_OVERRIDE; + + virtual void OnConnectSuccess(enum SocketType aSocketType) MOZ_OVERRIDE; + virtual void OnConnectError(enum SocketType aSocketType) MOZ_OVERRIDE; + virtual void OnDisconnect(enum SocketType aSocketType) MOZ_OVERRIDE; nsCOMPtr GetThread() { return mThread; diff --git a/ipc/nfc/Nfc.cpp b/ipc/nfc/Nfc.cpp index 62b96d5ab56..01e360b4e33 100644 --- a/ipc/nfc/Nfc.cpp +++ b/ipc/nfc/Nfc.cpp @@ -209,14 +209,23 @@ NfcConsumer::ReceiveSocketData(nsAutoPtr& aData) void NfcConsumer::OnConnectSuccess() { - // Nothing to do here. CHROMIUM_LOG("NFC: %s\n", __FUNCTION__); + + if (mListener) { + mListener->OnConnectSuccess(NfcSocketListener::STREAM_SOCKET); + } + // Nothing to do here. } void NfcConsumer::OnConnectError() { CHROMIUM_LOG("NFC: %s\n", __FUNCTION__); + + if (mListener) { + mListener->OnConnectError(NfcSocketListener::STREAM_SOCKET); + } + Close(); } @@ -224,6 +233,10 @@ void NfcConsumer::OnDisconnect() { CHROMIUM_LOG("NFC: %s\n", __FUNCTION__); + + if (mListener) { + mListener->OnDisconnect(NfcSocketListener::STREAM_SOCKET); + } if (!mShutdown) { Connect(new NfcConnector(), mAddress.get(), GetSuggestedConnectDelayMs()); } diff --git a/ipc/nfc/Nfc.h b/ipc/nfc/Nfc.h index 8f0b9683fb5..3a88101789d 100644 --- a/ipc/nfc/Nfc.h +++ b/ipc/nfc/Nfc.h @@ -17,7 +17,15 @@ namespace ipc { class NfcSocketListener { public: + enum SocketType { + STREAM_SOCKET + }; + virtual void ReceiveSocketData(nsAutoPtr& aData) = 0; + + virtual void OnConnectSuccess(enum SocketType aSocketType) = 0; + virtual void OnConnectError(enum SocketType aSocketType) = 0; + virtual void OnDisconnect(enum SocketType aSocketType) = 0; }; class NfcConsumer MOZ_FINAL : public mozilla::ipc::StreamSocket