dom/nfc/MozNdefRecord.h
author Bas Schouten <bschouten@mozilla.com>
Mon, 11 Nov 2013 12:42:07 +1300
changeset 155112 f2e964f107992348465e513b95f604b7732a8345
parent 154774 cfbcc835f71c26e9e9a44cee5467f89e646c6bf6
child 159208 b237796ae6e599394a99a77c7955fd158804fb77
permissions -rw-r--r--
Bug 939049 - Part 2: Add generic ComputeLength code for backends with no such functionality. r=jrmuizel

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */

/* Copyright © 2013 Deutsche Telekom, Inc. */

#ifndef mozilla_dom_MozNdefRecord_h__
#define mozilla_dom_MozNdefRecord_h__

#include "mozilla/Attributes.h"
#include "mozilla/ErrorResult.h"
#include "nsCycleCollectionParticipant.h"
#include "nsWrapperCache.h"
#include "jsapi.h"

#include "nsIDocument.h"

struct JSContext;

namespace mozilla {
namespace dom {

class MozNdefRecord MOZ_FINAL : public nsISupports,
                                public nsWrapperCache
{
public:
  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MozNdefRecord)

public:

  MozNdefRecord(nsPIDOMWindow* aWindow,
                uint8_t aTnf, const nsAString& aType,
                const nsAString& aId, const nsAString& aPlayload);

  ~MozNdefRecord();

  nsIDOMWindow* GetParentObject() const
  {
    return mWindow;
  }

  virtual JSObject* WrapObject(JSContext* aCx,
                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;

  static already_AddRefed<MozNdefRecord> Constructor(
                                           const GlobalObject& aGlobal,
                                           uint8_t aTnf, const nsAString& aType,
                                           const nsAString& aId,
                                           const nsAString& aPayload,
                                           ErrorResult& aRv);

  uint8_t Tnf() const
  {
    return mTnf;
  }

  void GetType(nsString& aType) const
  {
    aType = mType;
  }

  void GetId(nsString& aId) const
  {
    aId = mId;
  }

  void GetPayload(nsString& aPayload) const
  {
    aPayload = mPayload;
  }

private:
  MozNdefRecord() MOZ_DELETE;
  nsRefPtr<nsPIDOMWindow> mWindow;

  uint8_t mTnf;
  nsString mType;
  nsString mId;
  nsString mPayload;
};

} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_MozNdefRecord_h__