diff -r 000000000000 -r 6474c204b198 dom/fmradio/FMRadio.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dom/fmradio/FMRadio.h Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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_FMRadio_h +#define mozilla_dom_FMRadio_h + +#include "AudioChannelAgent.h" +#include "FMRadioCommon.h" +#include "mozilla/DOMEventTargetHelper.h" +#include "mozilla/HalTypes.h" +#include "nsCycleCollectionParticipant.h" +#include "nsWeakReference.h" + +class nsPIDOMWindow; +class nsIScriptContext; + +BEGIN_FMRADIO_NAMESPACE + +class DOMRequest; + +class FMRadio MOZ_FINAL : public DOMEventTargetHelper + , public hal::SwitchObserver + , public FMRadioEventObserver + , public nsSupportsWeakReference + , public nsIAudioChannelAgentCallback + , public nsIDOMEventListener + +{ + friend class FMRadioRequest; + +public: + FMRadio(); + + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIAUDIOCHANNELAGENTCALLBACK + + NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper) + + void Init(nsPIDOMWindow *aWindow); + void Shutdown(); + + /* hal::SwitchObserver */ + virtual void Notify(const hal::SwitchEvent& aEvent) MOZ_OVERRIDE; + /* FMRadioEventObserver */ + virtual void Notify(const FMRadioEventType& aType) MOZ_OVERRIDE; + + nsPIDOMWindow* GetParentObject() const + { + return GetOwner(); + } + + virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; + + static bool Enabled(); + + bool AntennaAvailable() const; + + Nullable GetFrequency() const; + + double FrequencyUpperBound() const; + + double FrequencyLowerBound() const; + + double ChannelWidth() const; + + already_AddRefed Enable(double aFrequency); + + already_AddRefed Disable(); + + already_AddRefed SetFrequency(double aFrequency); + + already_AddRefed SeekUp(); + + already_AddRefed SeekDown(); + + already_AddRefed CancelSeek(); + + IMPL_EVENT_HANDLER(enabled); + IMPL_EVENT_HANDLER(disabled); + IMPL_EVENT_HANDLER(antennaavailablechange); + IMPL_EVENT_HANDLER(frequencychange); + + // nsIDOMEventListener + NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent); + +private: + ~FMRadio(); + + void SetCanPlay(bool aCanPlay); + void EnableAudioChannelAgent(); + + hal::SwitchState mHeadphoneState; + bool mAudioChannelAgentEnabled; + bool mHasInternalAntenna; + bool mIsShutdown; + + nsCOMPtr mAudioChannelAgent; +}; + +END_FMRADIO_NAMESPACE + +#endif // mozilla_dom_FMRadio_h +