dom/fmradio/ipc/FMRadioChild.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:61e27c165aed
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/. */
6
7 #ifndef mozilla_dom_fmradiochild_h__
8 #define mozilla_dom_fmradiochild_h__
9
10 #include "FMRadioCommon.h"
11 #include "FMRadioService.h"
12 #include "mozilla/dom/PFMRadioChild.h"
13 #include "mozilla/StaticPtr.h"
14
15 BEGIN_FMRADIO_NAMESPACE
16
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();
31
32 void SendRequest(FMRadioReplyRunnable* aReplyRunnable,
33 FMRadioRequestArgs aArgs);
34
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;
41
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;
50
51 virtual void AddObserver(FMRadioEventObserver* aObserver) MOZ_OVERRIDE;
52 virtual void RemoveObserver(FMRadioEventObserver* aObserver) MOZ_OVERRIDE;
53
54 virtual void EnableAudio(bool aAudioEnabled) MOZ_OVERRIDE;
55
56 /* PFMRadioChild */
57 virtual bool
58 Recv__delete__() MOZ_OVERRIDE;
59
60 virtual bool
61 RecvNotifyFrequencyChanged(const double& aFrequency) MOZ_OVERRIDE;
62
63 virtual bool
64 RecvNotifyEnabledChanged(const bool& aEnabled,
65 const double& aFrequency) MOZ_OVERRIDE;
66
67 virtual PFMRadioRequestChild*
68 AllocPFMRadioRequestChild(const FMRadioRequestArgs& aArgs) MOZ_OVERRIDE;
69
70 virtual bool
71 DeallocPFMRadioRequestChild(PFMRadioRequestChild* aActor) MOZ_OVERRIDE;
72
73 private:
74 FMRadioChild();
75
76 void Init();
77
78 inline void NotifyFMRadioEvent(FMRadioEventType aType);
79
80 bool mEnabled;
81 double mFrequency;
82 double mUpperBound;
83 double mLowerBound;
84 double mChannelWidth;
85
86 FMRadioEventObserverList mObserverList;
87
88 private:
89 static StaticAutoPtr<FMRadioChild> sFMRadioChild;
90 };
91
92 END_FMRADIO_NAMESPACE
93
94 #endif // mozilla_dom_fmradiochild_h__
95

mercurial