/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef NfcService_h #define NfcService_h #include #include "mozilla/ipc/ListenSocketConsumer.h" #include #include "mozilla/ipc/StreamSocketConsumer.h" #include "nsCOMPtr.h" #include "nsINfcService.h" #include "NfcMessageHandler.h" class nsIThread; namespace mozilla { namespace dom { class NfcEventOptions; } // namespace dom class NfcService final : public nsINfcService , public mozilla::ipc::StreamSocketConsumer , public mozilla::ipc::ListenSocketConsumer { public: NS_DECL_ISUPPORTS NS_DECL_NSINFCSERVICE static already_AddRefed FactoryCreate(); void DispatchNfcEvent(const mozilla::dom::NfcEventOptions& aOptions); bool PostToNfcDaemon(const uint8_t* aData, size_t aSize); nsCOMPtr GetThread() { return mThread; } // Methods for |StreamSocketConsumer| and |ListenSocketConsumer| // void ReceiveSocketData( int aIndex, nsAutoPtr& aBuffer) override; void OnConnectSuccess(int aIndex) override; void OnConnectError(int aIndex) override; void OnDisconnect(int aIndex) override; private: enum SocketType { LISTEN_SOCKET, STREAM_SOCKET }; NfcService(); ~NfcService(); nsCOMPtr mThread; nsCOMPtr mListener; nsRefPtr mListenSocket; nsRefPtr mStreamSocket; nsAutoPtr mHandler; nsCString mListenSocketName; }; } // namespace mozilla #endif // NfcService_h