Bug 1686581 [wpt PR 27175] - [manifest] Explicitly terminate the multiprocessing...
[gecko.git] / image / MultipartImage.h
blob1f8d18dc55275a2d527ff0f325b718816a293152
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_image_MultipartImage_h
7 #define mozilla_image_MultipartImage_h
9 #include "ImageWrapper.h"
10 #include "IProgressObserver.h"
11 #include "ProgressTracker.h"
13 namespace mozilla {
14 namespace image {
16 class NextPartObserver;
18 /**
19 * An Image wrapper that implements support for multipart/x-mixed-replace
20 * images.
22 class MultipartImage : public ImageWrapper, public IProgressObserver {
23 public:
24 MOZ_DECLARE_REFCOUNTED_TYPENAME(MultipartImage)
25 // We need to always declare refcounting here, because
26 // IProgressObserver has pure-virtual refcounting.
27 NS_DECL_ISUPPORTS_INHERITED
29 void BeginTransitionToPart(Image* aNextPart);
31 // Overridden ImageWrapper methods:
32 virtual already_AddRefed<imgIContainer> Unwrap() override;
33 virtual already_AddRefed<ProgressTracker> GetProgressTracker() override;
34 virtual void SetProgressTracker(ProgressTracker* aTracker) override;
35 virtual nsresult OnImageDataAvailable(nsIRequest* aRequest,
36 nsISupports* aContext,
37 nsIInputStream* aInStr,
38 uint64_t aSourceOffset,
39 uint32_t aCount) override;
40 virtual nsresult OnImageDataComplete(nsIRequest* aRequest,
41 nsISupports* aContext, nsresult aStatus,
42 bool aLastPart) override;
44 // We don't support locking or track animation consumers for individual parts,
45 // so we override these methods to do nothing.
46 NS_IMETHOD LockImage() override { return NS_OK; }
47 NS_IMETHOD UnlockImage() override { return NS_OK; }
48 virtual void IncrementAnimationConsumers() override {}
49 virtual void DecrementAnimationConsumers() override {}
50 #ifdef DEBUG
51 virtual uint32_t GetAnimationConsumers() override { return 1; }
52 #endif
54 // Overridden IProgressObserver methods:
55 virtual void Notify(int32_t aType, const nsIntRect* aRect = nullptr) override;
56 virtual void OnLoadComplete(bool aLastPart) override;
57 virtual void SetHasImage() override;
58 virtual bool NotificationsDeferred() const override;
59 virtual void MarkPendingNotify() override;
60 virtual void ClearPendingNotify() override;
62 protected:
63 virtual ~MultipartImage();
65 private:
66 friend class ImageFactory;
67 friend class NextPartObserver;
69 explicit MultipartImage(Image* aFirstPart);
70 void Init();
72 void FinishTransition();
74 RefPtr<ProgressTracker> mTracker;
75 RefPtr<NextPartObserver> mNextPartObserver;
76 RefPtr<Image> mNextPart;
77 bool mPendingNotify : 1;
80 } // namespace image
81 } // namespace mozilla
83 #endif // mozilla_image_MultipartImage_h