michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* Copyright © 2013 Deutsche Telekom, Inc. */ michael@0: michael@0: #ifndef mozilla_dom_MozNDEFRecord_h__ michael@0: #define mozilla_dom_MozNDEFRecord_h__ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/ErrorResult.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "nsWrapperCache.h" michael@0: #include "jsapi.h" michael@0: michael@0: #include "nsIDocument.h" michael@0: michael@0: #include "mozilla/dom/TypedArray.h" michael@0: #include "jsfriendapi.h" michael@0: #include "js/GCAPI.h" michael@0: michael@0: struct JSContext; michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class MozNDEFRecord MOZ_FINAL : public nsISupports, michael@0: public nsWrapperCache michael@0: { michael@0: public: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MozNDEFRecord) michael@0: michael@0: public: michael@0: michael@0: MozNDEFRecord(JSContext* aCx, nsPIDOMWindow* aWindow, uint8_t aTnf, michael@0: const Optional& aType, michael@0: const Optional& aId, michael@0: const Optional& aPlayload); michael@0: michael@0: ~MozNDEFRecord(); michael@0: michael@0: nsIDOMWindow* GetParentObject() const michael@0: { michael@0: return mWindow; michael@0: } michael@0: michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: michael@0: static already_AddRefed michael@0: Constructor(const GlobalObject& aGlobal, uint8_t aTnf, michael@0: const Optional& aType, michael@0: const Optional& aId, michael@0: const Optional& aPayload, ErrorResult& aRv); michael@0: michael@0: uint8_t Tnf() const michael@0: { michael@0: return mTnf; michael@0: } michael@0: michael@0: void GetType(JSContext* cx, JS::MutableHandle retval) const michael@0: { michael@0: if (mType) { michael@0: JS::ExposeObjectToActiveJS(mType); michael@0: } michael@0: retval.set(mType); michael@0: } michael@0: michael@0: void GetId(JSContext* cx, JS::MutableHandle retval) const michael@0: { michael@0: if (mId) { michael@0: JS::ExposeObjectToActiveJS(mId); michael@0: } michael@0: retval.set(mId); michael@0: } michael@0: michael@0: void GetPayload(JSContext* cx, JS::MutableHandle retval) const michael@0: { michael@0: if (mPayload) { michael@0: JS::ExposeObjectToActiveJS(mPayload); michael@0: } michael@0: retval.set(mPayload); michael@0: } michael@0: michael@0: private: michael@0: MozNDEFRecord() MOZ_DELETE; michael@0: nsRefPtr mWindow; michael@0: void HoldData(); michael@0: void DropData(); michael@0: michael@0: uint8_t mTnf; michael@0: JS::Heap mType; michael@0: JS::Heap mId; michael@0: JS::Heap mPayload; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_dom_MozNDEFRecord_h__