Bug 1526591 - Remove devtools.inspector.shapesHighlighter.enabled pref. r=rcaliman
[gecko.git] / dom / media / MediaResourceCallback.h
blobf5f3a74632068a4650a28d2e14cfdb09dca66517
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/. */
7 #ifndef MediaResourceCallback_h_
8 #define MediaResourceCallback_h_
10 #include "DecoderDoctorLogger.h"
11 #include "nsError.h"
12 #include "nsISupportsImpl.h"
13 #include "MediaResult.h"
15 namespace mozilla {
17 class AbstractThread;
18 class MediaDecoderOwner;
19 class MediaResource;
21 DDLoggedTypeDeclName(MediaResourceCallback);
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.
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.
32 class MediaResourceCallback
33 : public DecoderDoctorLifeLogger<MediaResourceCallback> {
34 public:
35 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaResourceCallback);
37 // Return an abstract thread on which to run main thread runnables.
38 virtual AbstractThread* AbstractMainThread() const { return nullptr; }
40 // Returns a weak reference to the media decoder owner.
41 virtual MediaDecoderOwner* GetMediaOwner() const { return nullptr; }
43 // Notify that a network error is encountered.
44 virtual void NotifyNetworkError(const MediaResult& aError) {}
46 // Notify that data arrives on the stream and is read into the cache.
47 virtual void NotifyDataArrived() {}
49 // Notify download is ended.
50 // NOTE: this can be called with the media cache lock held, so don't
51 // block or do anything which might try to acquire a lock!
52 virtual void NotifyDataEnded(nsresult aStatus) {}
54 // Notify that the principal of MediaResource has changed.
55 virtual void NotifyPrincipalChanged() {}
57 // Notify that the "cache suspended" status of MediaResource changes.
58 virtual void NotifySuspendedStatusChanged(bool aSuspendedByCache) {}
60 protected:
61 virtual ~MediaResourceCallback() {}
64 } // namespace mozilla
66 #endif // MediaResourceCallback_h_