
The HTMLMediaElement, for example, contains spec text which states any ongoing fetch process must be "stopped". The spec does not indicate how to do this, so our implementation is rather ad-hoc. Our current implementation may cause a crash in places that assume one of the fetch algorithms that we set to null is *not* null. For example: if (fetch_params.process_response) { queue_fetch_task([]() { fetch_params.process_response(); }; } If the fetch process is stopped after queuing the fetch task, but not before the fetch task is run, we will crash when running this fetch algorithm. We now track queued fetch tasks on the fetch controller. When the fetch process is stopped, we cancel any such pending task. It is a little bit awkward maintaining a fetch task ID. Ideally, we could use the underlying task ID throughout. But we do not have access to the underlying task nor its ID when the task is running, at which point we need some ID to remove from the pending task list.
23 lines
569 B
C++
23 lines
569 B
C++
/*
|
|
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Variant.h>
|
|
#include <LibJS/Forward.h>
|
|
#include <LibJS/Heap/GCPtr.h>
|
|
#include <LibJS/SafeFunction.h>
|
|
#include <LibWeb/Forward.h>
|
|
|
|
namespace Web::Fetch::Infrastructure {
|
|
|
|
// FIXME: 'or a parallel queue'
|
|
using TaskDestination = Variant<Empty, JS::NonnullGCPtr<JS::Object>>;
|
|
|
|
int queue_fetch_task(JS::Object&, JS::SafeFunction<void()>);
|
|
int queue_fetch_task(JS::NonnullGCPtr<FetchController>, JS::Object&, JS::SafeFunction<void()>);
|
|
|
|
}
|