Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_fmradiochild_h__
8 #define mozilla_dom_fmradiochild_h__
10 #include "FMRadioCommon.h"
11 #include "FMRadioService.h"
12 #include "mozilla/dom/PFMRadioChild.h"
13 #include "mozilla/StaticPtr.h"
15 BEGIN_FMRADIO_NAMESPACE
17 /**
18 * FMRadioChild plays two roles:
19 * - Kind of proxy of FMRadioService
20 * Redirect all the requests coming from web content to FMRadioService
21 * in parent through IPC channel.
22 * - Child Actor of PFMRadio
23 * IPC channel to transfer the requests.
24 */
25 class FMRadioChild MOZ_FINAL : public IFMRadioService
26 , public PFMRadioChild
27 {
28 public:
29 static FMRadioChild* Singleton();
30 ~FMRadioChild();
32 void SendRequest(FMRadioReplyRunnable* aReplyRunnable,
33 FMRadioRequestArgs aArgs);
35 /* IFMRadioService */
36 virtual bool IsEnabled() const MOZ_OVERRIDE;
37 virtual double GetFrequency() const MOZ_OVERRIDE;
38 virtual double GetFrequencyUpperBound() const MOZ_OVERRIDE;
39 virtual double GetFrequencyLowerBound() const MOZ_OVERRIDE;
40 virtual double GetChannelWidth() const MOZ_OVERRIDE;
42 virtual void Enable(double aFrequency,
43 FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE;
44 virtual void Disable(FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE;
45 virtual void SetFrequency(double frequency,
46 FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE;
47 virtual void Seek(mozilla::hal::FMRadioSeekDirection aDirection,
48 FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE;
49 virtual void CancelSeek(FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE;
51 virtual void AddObserver(FMRadioEventObserver* aObserver) MOZ_OVERRIDE;
52 virtual void RemoveObserver(FMRadioEventObserver* aObserver) MOZ_OVERRIDE;
54 virtual void EnableAudio(bool aAudioEnabled) MOZ_OVERRIDE;
56 /* PFMRadioChild */
57 virtual bool
58 Recv__delete__() MOZ_OVERRIDE;
60 virtual bool
61 RecvNotifyFrequencyChanged(const double& aFrequency) MOZ_OVERRIDE;
63 virtual bool
64 RecvNotifyEnabledChanged(const bool& aEnabled,
65 const double& aFrequency) MOZ_OVERRIDE;
67 virtual PFMRadioRequestChild*
68 AllocPFMRadioRequestChild(const FMRadioRequestArgs& aArgs) MOZ_OVERRIDE;
70 virtual bool
71 DeallocPFMRadioRequestChild(PFMRadioRequestChild* aActor) MOZ_OVERRIDE;
73 private:
74 FMRadioChild();
76 void Init();
78 inline void NotifyFMRadioEvent(FMRadioEventType aType);
80 bool mEnabled;
81 double mFrequency;
82 double mUpperBound;
83 double mLowerBound;
84 double mChannelWidth;
86 FMRadioEventObserverList mObserverList;
88 private:
89 static StaticAutoPtr<FMRadioChild> sFMRadioChild;
90 };
92 END_FMRADIO_NAMESPACE
94 #endif // mozilla_dom_fmradiochild_h__