blob: 3e0c42d2464c4ddacf39e4193702c6ac0aa6cce1 [file] [log] [blame]
// Copyright 2019 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 "third_party/blink/renderer/core/core_export.h"
#include "v8/include/v8.h"
namespace blink {
// Operations from the "Miscellaneous Operations" section of the standard:
class ExceptionState;
class ScriptState;
class StrategySizeAlgorithm;
class StreamAlgorithm;
class StreamStartAlgorithm;
// This is slightly different than the version in the standard
// as
// it doesn't require the number of expected arguments, algoArgCount, to be
// specified. Also, it only supports 0 or 1 extraArgs, instead of an arbitrary
// number. Use an empty value for |extra_arg| to mean 0 extraArgs.
// |method_name_for_error| supplies a more helpful name for the method to be
// used in exception messages. For example, if |method_name| is "write",
// |method_name_for_error| might be "underlyingSink.write".
CORE_EXPORT StreamAlgorithm* CreateAlgorithmFromUnderlyingMethod(
v8::Local<v8::Object> underlying_object,
const char* method_name,
const char* method_name_for_error,
v8::MaybeLocal<v8::Value> extra_arg,
// Create a StreamStartAlgorithm from the "start" method on |underlying_object|.
// Unlike other algorithms, the lookup of the method on the object is done at
// execution time rather than algorithm creation time. |method_name_for_error|
// is used in exception messages. It is not copied so must remain valid until
// the algorithm is run.
CORE_EXPORT StreamStartAlgorithm* CreateStartAlgorithm(
v8::Local<v8::Object> underlying_object,
const char* method_name_for_error,
v8::Local<v8::Value> controller);
// Used in place of InvokeOrNoop in spec. Always takes 1 argument.
CORE_EXPORT v8::MaybeLocal<v8::Value> CallOrNoop1(ScriptState*,
v8::Local<v8::Object> object,
const char* method_name,
const char* name_for_error,
v8::Local<v8::Value> arg0,
// "PromiseCall(F, V, args)"
// "F" is called |method| here
// "V" is called |recv| here
// "args" becomes |argc| and |argv| here.
CORE_EXPORT v8::Local<v8::Promise> PromiseCall(ScriptState*,
v8::Local<v8::Function> method,
v8::Local<v8::Object> recv,
int argc,
v8::Local<v8::Value> argv[]);
// Unlike in the standard, the caller needs to handle the conversion of the
// value to a Number.
CORE_EXPORT double ValidateAndNormalizeHighWaterMark(double high_water_mark,
CORE_EXPORT StrategySizeAlgorithm* MakeSizeAlgorithmFromSizeFunction(
v8::Local<v8::Value> size,
// Implements "a promise rejected with" from the INFRA standard.
CORE_EXPORT v8::Local<v8::Promise> PromiseReject(ScriptState*,
// Implements "a promise resolved with" from the INFRA standard.
CORE_EXPORT v8::Local<v8::Promise> PromiseResolve(ScriptState*,
// Implements "a promise resolved with *undefined*".
CORE_EXPORT v8::Local<v8::Promise> PromiseResolveWithUndefined(ScriptState*);
} // namespace blink