ScriptValueSerializer::StateBase* ScriptValueSerializerForModules::doSerializeValue(v8::Local<v8::Value> value, ScriptValueSerializer::StateBase* next)
{
    bool isDOMFileSystem = V8DOMFileSystem::hasInstance(value, isolate());
    if (isDOMFileSystem || V8CryptoKey::hasInstance(value, isolate())) {
        v8::Local<v8::Object> jsObject = value.As<v8::Object>();
        if (jsObject.IsEmpty())
            return handleError(DataCloneError, "An object could not be cloned.", next);
        greyObject(jsObject);

        if (isDOMFileSystem)
            return writeDOMFileSystem(value, next);

        if (!writeCryptoKey(value))
            return handleError(DataCloneError, "Couldn't serialize key data", next);
        return 0;
    }
    return ScriptValueSerializer::doSerializeValue(value, next);
}
ScriptValueSerializer::StateBase*
ScriptValueSerializerForModules::doSerializeObject(
    v8::Local<v8::Object> jsObject,
    StateBase* next) {
  DCHECK(!jsObject.IsEmpty());

  if (V8DOMFileSystem::hasInstance(jsObject, isolate())) {
    greyObject(jsObject);
    return writeDOMFileSystem(jsObject, next);
  }
  if (V8CryptoKey::hasInstance(jsObject, isolate())) {
    greyObject(jsObject);
    if (!writeCryptoKey(jsObject))
      return handleError(Status::DataCloneError, "Couldn't serialize key data",
                         next);
    return nullptr;
  }
  if (V8RTCCertificate::hasInstance(jsObject, isolate())) {
    greyObject(jsObject);
    return writeRTCCertificate(jsObject, next);
  }

  return ScriptValueSerializer::doSerializeObject(jsObject, next);
}