blob: 1915edd025eb90529103d36fc6da411cde466455 [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/callback_forward.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/dom/events/event_target.h"
#include "third_party/blink/renderer/platform/heap/heap_allocator.h"
#include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink {
class ExecutionContext;
// Implementation of
class CORE_EXPORT AbortSignal : public EventTargetWithInlineData {
explicit AbortSignal(ExecutionContext*);
~AbortSignal() override;
// abort_signal.idl
bool aborted() const { return aborted_flag_; }
const AtomicString& InterfaceName() const override;
ExecutionContext* GetExecutionContext() const override;
// Internal API
// The "add an algorithm" algorithm from the standard:
// for dependent features to call
// to be notified when abort has been signalled. Callers should pass a
// OnceClosure holding a weak pointer, unless the object needs to receive a
// cancellation signal even after it otherwise would have been destroyed.
void AddAlgorithm(base::OnceClosure algorithm);
// The "remove an algorithm" algorithm
// is not yet implemented as
// it has no users currently. See
// for discussion.
// The "To signal abort" algorithm from the standard:
// Run all algorithms that were
// added by AddAlgorithm(), in order of addition, then fire an "abort"
// event. Does nothing if called more than once.
void SignalAbort();
// The "follow" algorithm from the standard:
// |this| is the followingSignal described in the standard.
void Follow(AbortSignal* parentSignal);
virtual bool IsTaskSignal() const { return false; }
void Trace(Visitor*) override;
void AddSignalAbortAlgorithm(AbortSignal*);
bool aborted_flag_ = false;
Vector<base::OnceClosure> abort_algorithms_;
HeapVector<Member<AbortSignal>> dependent_signals_;
Member<ExecutionContext> execution_context_;
} // namespace blink