/src/mozilla-central/dom/media/MediaResourceCallback.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 MediaResourceCallback_h_ |
8 | | #define MediaResourceCallback_h_ |
9 | | |
10 | | #include "DecoderDoctorLogger.h" |
11 | | #include "nsError.h" |
12 | | #include "nsISupportsImpl.h" |
13 | | #include "MediaResult.h" |
14 | | |
15 | | namespace mozilla { |
16 | | |
17 | | class AbstractThread; |
18 | | class MediaDecoderOwner; |
19 | | class MediaResource; |
20 | | |
21 | | DDLoggedTypeDeclName(MediaResourceCallback); |
22 | | |
23 | | /** |
24 | | * A callback used by MediaResource (sub-classes like FileMediaResource, |
25 | | * RtspMediaResource, and ChannelMediaResource) to notify various events. |
26 | | * Currently this is implemented by MediaDecoder only. |
27 | | * |
28 | | * Since this class has no pure virtual function, it is convenient to write |
29 | | * gtests for the readers without using a mock MediaResource when you don't |
30 | | * care about the events notified by the MediaResource. |
31 | | */ |
32 | | class MediaResourceCallback |
33 | | : public DecoderDoctorLifeLogger<MediaResourceCallback> |
34 | | { |
35 | | public: |
36 | | NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaResourceCallback); |
37 | | |
38 | | // Return an abstract thread on which to run main thread runnables. |
39 | 0 | virtual AbstractThread* AbstractMainThread() const { return nullptr; } |
40 | | |
41 | | // Returns a weak reference to the media decoder owner. |
42 | 0 | virtual MediaDecoderOwner* GetMediaOwner() const { return nullptr; } |
43 | | |
44 | | // Notify that a network error is encountered. |
45 | 0 | virtual void NotifyNetworkError(const MediaResult& aError) {} |
46 | | |
47 | | // Notify that data arrives on the stream and is read into the cache. |
48 | 0 | virtual void NotifyDataArrived() {} |
49 | | |
50 | | // Notify download is ended. |
51 | | // NOTE: this can be called with the media cache lock held, so don't |
52 | | // block or do anything which might try to acquire a lock! |
53 | 0 | virtual void NotifyDataEnded(nsresult aStatus) {} |
54 | | |
55 | | // Notify that the principal of MediaResource has changed. |
56 | 0 | virtual void NotifyPrincipalChanged() {} |
57 | | |
58 | | // Notify that the "cache suspended" status of MediaResource changes. |
59 | 0 | virtual void NotifySuspendedStatusChanged(bool aSuspendedByCache) {} |
60 | | |
61 | | protected: |
62 | 0 | virtual ~MediaResourceCallback() {} |
63 | | }; |
64 | | |
65 | | } // namespace mozilla |
66 | | |
67 | | #endif //MediaResourceCallback_h_ |