/src/mozilla-central/dom/audiochannel/AudioChannelAgent.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=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 |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_dom_audio_channel_agent_h__ |
8 | | #define mozilla_dom_audio_channel_agent_h__ |
9 | | |
10 | | #include "nsIAudioChannelAgent.h" |
11 | | #include "nsCycleCollectionParticipant.h" |
12 | | #include "nsCOMPtr.h" |
13 | | #include "nsWeakPtr.h" |
14 | | |
15 | | class nsPIDOMWindowInner; |
16 | | class nsPIDOMWindowOuter; |
17 | | |
18 | | namespace mozilla { |
19 | | namespace dom { |
20 | | |
21 | | class AudioPlaybackConfig; |
22 | | |
23 | | /* Header file */ |
24 | | class AudioChannelAgent : public nsIAudioChannelAgent |
25 | | { |
26 | | public: |
27 | | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
28 | | NS_DECL_NSIAUDIOCHANNELAGENT |
29 | | |
30 | | NS_DECL_CYCLE_COLLECTION_CLASS(AudioChannelAgent) |
31 | | |
32 | | AudioChannelAgent(); |
33 | | |
34 | | void WindowVolumeChanged(); |
35 | | void WindowSuspendChanged(nsSuspendedTypes aSuspend); |
36 | | void WindowAudioCaptureChanged(uint64_t aInnerWindowID, bool aCapture); |
37 | | |
38 | | nsPIDOMWindowOuter* Window() const |
39 | 0 | { |
40 | 0 | return mWindow; |
41 | 0 | } |
42 | | |
43 | | uint64_t WindowID() const; |
44 | | uint64_t InnerWindowID() const; |
45 | | |
46 | | bool IsPlayingStarted() const; |
47 | | bool ShouldBlockMedia() const; |
48 | | |
49 | | private: |
50 | | virtual ~AudioChannelAgent(); |
51 | | |
52 | | AudioPlaybackConfig GetMediaConfig(); |
53 | | bool IsDisposableSuspend(nsSuspendedTypes aSuspend) const; |
54 | | |
55 | | // Returns mCallback if that's non-null, or otherwise tries to get an |
56 | | // nsIAudioChannelAgentCallback out of mWeakCallback. |
57 | | already_AddRefed<nsIAudioChannelAgentCallback> GetCallback(); |
58 | | |
59 | | nsresult InitInternal(nsPIDOMWindowInner* aWindow, |
60 | | nsIAudioChannelAgentCallback* aCallback, |
61 | | bool aUseWeakRef); |
62 | | |
63 | | void Shutdown(); |
64 | | |
65 | | nsresult FindCorrectWindow(nsPIDOMWindowInner* aWindow); |
66 | | |
67 | | nsCOMPtr<nsPIDOMWindowOuter> mWindow; |
68 | | nsCOMPtr<nsIAudioChannelAgentCallback> mCallback; |
69 | | |
70 | | nsWeakPtr mWeakCallback; |
71 | | |
72 | | uint64_t mInnerWindowID; |
73 | | bool mIsRegToService; |
74 | | }; |
75 | | |
76 | | } // namespace dom |
77 | | } // namespace mozilla |
78 | | |
79 | | |
80 | | #endif |