Bug 1123651: Inherit |NfcConsumer| from |StreamSocket|, r=allstars.chh

With this patch, |NfcConsumer| inherits from |StreamSocket| instead
of |UnixSocketConsumer|. Some methods have been renamed. |NfcConsumer|
now contains the method |GetIO|, which is required by |StreamSocket|
for integration with |ListenSocket|.
This commit is contained in:
Thomas Zimmermann 2015-01-21 10:59:21 +01:00
parent 0215081264
commit 5cbe35fbd5
2 changed files with 15 additions and 7 deletions

View File

@ -22,6 +22,7 @@
#include "jsfriendapi.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/ipc/UnixSocketConnector.h"
#include "nsThreadUtils.h" // For NS_IsMainThread.
using namespace mozilla::ipc;
@ -172,7 +173,7 @@ NfcConsumer::NfcConsumer(NfcSocketListener* aListener)
{
mAddress = NFC_SOCKET_NAME;
ConnectSocket(new NfcConnector(), mAddress.get());
Connect(new NfcConnector(), mAddress.get());
}
void
@ -181,7 +182,7 @@ NfcConsumer::Shutdown()
MOZ_ASSERT(NS_IsMainThread());
mShutdown = true;
CloseSocket();
Close();
}
bool
@ -216,7 +217,7 @@ void
NfcConsumer::OnConnectError()
{
CHROMIUM_LOG("NFC: %s\n", __FUNCTION__);
CloseSocket();
Close();
}
void
@ -224,10 +225,15 @@ NfcConsumer::OnDisconnect()
{
CHROMIUM_LOG("NFC: %s\n", __FUNCTION__);
if (!mShutdown) {
ConnectSocket(new NfcConnector(), mAddress.get(),
GetSuggestedConnectDelayMs());
Connect(new NfcConnector(), mAddress.get(), GetSuggestedConnectDelayMs());
}
}
ConnectionOrientedSocketIO*
NfcConsumer::GetIO()
{
return PrepareAccept(new NfcConnector());
}
} // namespace ipc
} // namespace mozilla

View File

@ -9,7 +9,7 @@
#ifndef mozilla_ipc_Nfc_h
#define mozilla_ipc_Nfc_h 1
#include <mozilla/ipc/UnixSocket.h>
#include <mozilla/ipc/StreamSocket.h>
namespace mozilla {
namespace ipc {
@ -20,7 +20,7 @@ public:
virtual void ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aData) = 0;
};
class NfcConsumer MOZ_FINAL : public mozilla::ipc::UnixSocketConsumer
class NfcConsumer MOZ_FINAL : public mozilla::ipc::StreamSocket
{
public:
NfcConsumer(NfcSocketListener* aListener);
@ -28,6 +28,8 @@ public:
void Shutdown();
bool PostToNfcDaemon(const uint8_t* aData, size_t aSize);
ConnectionOrientedSocketIO* GetIO() MOZ_OVERRIDE;
private:
void ReceiveSocketData(
nsAutoPtr<UnixSocketRawData>& aData) MOZ_OVERRIDE;