dom/events/NotifyAudioAvailableEvent.h
author Masayuki Nakano <masayuki@d-toybox.com>
Fri, 28 Feb 2014 23:58:42 +0900
changeset 171519 031dc7e7c0742dca42bbd82d866dffc097b0bbdf
parent 164033 dom/events/nsDOMNotifyAudioAvailableEvent.h@f017ae03bb6c453132c7023870557c4a5d469c97
child 172202 8b872592e44140baa088e3af474eaca9eb1d2701
permissions -rw-r--r--
Bug 975688 part.21 Rename nsDOMNotifyAudioAvailableEvent to mozilla::dom::NotifyAudioAvailableEvent r=smaug

/* -*- 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/. */

#ifndef mozilla_dom_NotifyAudioAvailableEvent_h_
#define mozilla_dom_NotifyAudioAvailableEvent_h_

#include "nsIDOMNotifyAudioAvailableEvent.h"
#include "nsDOMEvent.h"
#include "nsCycleCollectionParticipant.h"
#include "mozilla/dom/NotifyAudioAvailableEventBinding.h"

class nsPresContext;

namespace mozilla {
namespace dom {

class NotifyAudioAvailableEvent : public nsDOMEvent,
                                  public nsIDOMNotifyAudioAvailableEvent
{
public:
  NotifyAudioAvailableEvent(EventTarget* aOwner,
                            nsPresContext* aPresContext,
                            WidgetEvent* aEvent,
                            uint32_t aEventType,
                            float* aFrameBuffer,
                            uint32_t aFrameBufferLength,
                            float aTime);

  NS_DECL_ISUPPORTS_INHERITED
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
    NotifyAudioAvailableEvent, nsDOMEvent)

  NS_DECL_NSIDOMNOTIFYAUDIOAVAILABLEEVENT
  NS_FORWARD_NSIDOMEVENT(nsDOMEvent::)

  ~NotifyAudioAvailableEvent();

  virtual JSObject* WrapObject(JSContext* aCx,
                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
  {
    return NotifyAudioAvailableEventBinding::Wrap(aCx, aScope, this);
  }

  JSObject* GetFrameBuffer(JSContext* aCx, ErrorResult& aRv)
  {
    JS::Rooted<JS::Value> dummy(aCx);
    aRv = GetFrameBuffer(aCx, &dummy);
    return mCachedArray;
  }

  float Time()
  {
    return mTime;
  }

  void InitAudioAvailableEvent(const nsAString& aType,
                               bool aCanBubble,
                               bool aCancelable,
                               const Nullable<Sequence<float> >& aFrameBuffer,
                               uint32_t aFrameBufferLength,
                               float aTime,
                               bool aAllowAudioData,
                               ErrorResult& aRv);
private:
  nsAutoArrayPtr<float> mFrameBuffer;
  uint32_t mFrameBufferLength;
  float mTime;
  JS::Heap<JSObject*> mCachedArray;
  bool mAllowAudioData;
};

} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_NotifyAudioAvailableEvent_h_