When there is a pending promise for an ImageDecoder, we have no guarantee that JavaScript will keep the ImageDecoder itself while it waits for the promise to be resolved. As such, we need a strong reference to the ImageDecoder until the promises are fulfilled. This conflicts with how lifetimes were previously managed using weak pointers. Before shutdown would appropriately release the reference, but now it cannot due to the pending promises. As such we need to add explicit shutdown state trackers to perform this function. Differential Revision: https://phabricator.services.mozilla.com/D226145
65 lines
2.0 KiB
C++
65 lines
2.0 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef mozilla_dom_ImageDecoderReadRequest_h
|
|
#define mozilla_dom_ImageDecoderReadRequest_h
|
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
|
#include "mozilla/dom/ReadRequest.h"
|
|
|
|
namespace mozilla {
|
|
class MediaResult;
|
|
|
|
namespace image {
|
|
class SourceBuffer;
|
|
}
|
|
|
|
namespace dom {
|
|
class ImageDecoder;
|
|
class ReadableStream;
|
|
class ReadableStreamDefaultReader;
|
|
|
|
struct ImageDecoderReadRequest final : public ReadRequest {
|
|
public:
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ImageDecoderReadRequest, ReadRequest)
|
|
|
|
public:
|
|
explicit ImageDecoderReadRequest(image::SourceBuffer* aSourceBuffer);
|
|
|
|
bool Initialize(const GlobalObject& aGlobal, ImageDecoder* aDecoder,
|
|
ReadableStream& aStream);
|
|
void Destroy(bool aCancel);
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY void ChunkSteps(JSContext* aCx,
|
|
JS::Handle<JS::Value> aChunk,
|
|
ErrorResult& aRv) override;
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY void CloseSteps(JSContext* aCx,
|
|
ErrorResult& aRv) override;
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY void ErrorSteps(JSContext* aCx,
|
|
JS::Handle<JS::Value> aError,
|
|
ErrorResult& aRv) override;
|
|
|
|
private:
|
|
~ImageDecoderReadRequest() override;
|
|
|
|
void QueueRead();
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY void Read();
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY void Cancel();
|
|
void Complete(const MediaResult& aResult);
|
|
|
|
RefPtr<ImageDecoder> mDecoder;
|
|
RefPtr<ReadableStreamDefaultReader> mReader;
|
|
RefPtr<image::SourceBuffer> mSourceBuffer;
|
|
};
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|
|
|
|
#endif // mozilla_dom_ImageDecoderReadRequest_h
|