v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
v8::ValueSerializer::Delegate Class Referenceabstract

#include <v8-value-serializer.h>

Inheritance diagram for v8::ValueSerializer::Delegate:
Collaboration diagram for v8::ValueSerializer::Delegate:

Public Member Functions

virtual ~Delegate ()=default
 
virtual void ThrowDataCloneError (Local< String > message)=0
 
virtual bool HasCustomHostObject (Isolate *isolate)
 
virtual Maybe< bool > IsHostObject (Isolate *isolate, Local< Object > object)
 
virtual Maybe< bool > WriteHostObject (Isolate *isolate, Local< Object > object)
 
virtual Maybe< uint32_t > GetSharedArrayBufferId (Isolate *isolate, Local< SharedArrayBuffer > shared_array_buffer)
 
virtual Maybe< uint32_t > GetWasmModuleTransferId (Isolate *isolate, Local< WasmModuleObject > module)
 
virtual bool AdoptSharedValueConveyor (Isolate *isolate, SharedValueConveyor &&conveyor)
 
virtual void * ReallocateBufferMemory (void *old_buffer, size_t size, size_t *actual_size)
 
virtual void FreeBufferMemory (void *buffer)
 

Detailed Description

Definition at line 67 of file v8-value-serializer.h.

Constructor & Destructor Documentation

◆ ~Delegate()

virtual v8::ValueSerializer::Delegate::~Delegate ( )
virtualdefault

Member Function Documentation

◆ AdoptSharedValueConveyor()

bool v8::ValueSerializer::Delegate::AdoptSharedValueConveyor ( Isolate * isolate,
SharedValueConveyor && conveyor )
virtual

Called when the first shared value is serialized. All subsequent shared values will use the same conveyor.

The embedder must ensure the lifetime of the conveyor matches the lifetime of the serialized data.

If the embedder supports serializing shared values, this method should return true. Otherwise the embedder should throw an exception and return false.

This method is called at most once per serializer.

Reimplemented in v8::Serializer.

Definition at line 3267 of file api.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FreeBufferMemory()

void v8::ValueSerializer::Delegate::FreeBufferMemory ( void * buffer)
virtual

Frees a buffer allocated with |ReallocateBufferMemory|.

The default implementation uses the stdlib's free() function.

Reimplemented in v8::Serializer.

Definition at line 3283 of file api.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSharedArrayBufferId()

Maybe< uint32_t > v8::ValueSerializer::Delegate::GetSharedArrayBufferId ( Isolate * isolate,
Local< SharedArrayBuffer > shared_array_buffer )
virtual

Called when the ValueSerializer is going to serialize a SharedArrayBuffer object. The embedder must return an ID for the object, using the same ID if this SharedArrayBuffer has already been serialized in this buffer. When deserializing, this ID will be passed to ValueDeserializer::GetSharedArrayBufferFromId as |clone_id|.

If the object cannot be serialized, an exception should be thrown and Nothing<uint32_t>() returned.

Reimplemented in v8::Serializer.

Definition at line 3253 of file api.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetWasmModuleTransferId()

Maybe< uint32_t > v8::ValueSerializer::Delegate::GetWasmModuleTransferId ( Isolate * isolate,
Local< WasmModuleObject > module )
virtual

Reimplemented in v8::Serializer.

Definition at line 3262 of file api.cc.

Here is the call graph for this function:

◆ HasCustomHostObject()

bool v8::ValueSerializer::Delegate::HasCustomHostObject ( Isolate * isolate)
virtual

The embedder overrides this method to enable custom host object filter with Delegate::IsHostObject.

This method is called at most once per serializer.

Definition at line 3241 of file api.cc.

Here is the caller graph for this function:

◆ IsHostObject()

Maybe< bool > v8::ValueSerializer::Delegate::IsHostObject ( Isolate * isolate,
Local< Object > object )
virtual

The embedder overrides this method to determine if an JS object is a host object and needs to be serialized by the host.

Definition at line 3245 of file api.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReallocateBufferMemory()

void * v8::ValueSerializer::Delegate::ReallocateBufferMemory ( void * old_buffer,
size_t size,
size_t * actual_size )
virtual

Allocates memory for the buffer of at least the size provided. The actual size (which may be greater or equal) is written to |actual_size|. If no buffer has been allocated yet, nullptr will be provided.

If the memory cannot be allocated, nullptr should be returned. |actual_size| will be ignored. It is assumed that |old_buffer| is still valid in this case and has not been modified.

The default implementation uses the stdlib's realloc() function.

Reimplemented in v8::Serializer.

Definition at line 3276 of file api.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ThrowDataCloneError()

virtual void v8::ValueSerializer::Delegate::ThrowDataCloneError ( Local< String > message)
pure virtual

Handles the case where a DataCloneError would be thrown in the structured clone spec. Other V8 embedders may throw some other appropriate exception type.

Implemented in v8::Serializer.

Here is the caller graph for this function:

◆ WriteHostObject()

Maybe< bool > v8::ValueSerializer::Delegate::WriteHostObject ( Isolate * isolate,
Local< Object > object )
virtual

The embedder overrides this method to write some kind of host object, if possible. If not, a suitable exception should be thrown and Nothing<bool>() returned.

Definition at line 3231 of file api.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: