text: // Copyright 2014 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.
  
  // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
  
  #include "config.h"
  #include "V8SharedWorkerGlobalScope.h"
  
  #include "../../../../../out/target/product/victara/obj/GYP/shared_intermediates/blink/core/SharedWorkerGlobalScopeCoreConstructors.h"
  #include "../../../../../out/target/product/victara/obj/GYP/shared_intermediates/blink/modules/SharedWorkerGlobalScopeModulesConstructors.h"
  #include "bindings/core/v8/V8Blob.h"
  #include "bindings/core/v8/V8EventSource.h"
  #include "bindings/core/v8/V8File.h"
  #include "bindings/core/v8/V8FileReader.h"
  #include "bindings/core/v8/V8FileReaderSync.h"
  #include "bindings/core/v8/V8FormData.h"
  #include "bindings/core/v8/V8ImageData.h"
  #include "bindings/core/v8/V8MessageChannel.h"
  #include "bindings/core/v8/V8MessageEvent.h"
  #include "bindings/core/v8/V8SharedWorkerGlobalScope.h"
  #include "bindings/core/v8/V8URL.h"
  #include "bindings/core/v8/V8WorkerGlobalScope.h"
  #include "bindings/core/v8/V8WorkerLocation.h"
  #include "bindings/core/v8/V8WorkerNavigator.h"
  #include "bindings/core/v8/V8XMLHttpRequest.h"
  #include "bindings/modules/v8/V8NetworkInformation.h"
  #include "bindings/modules/v8/V8TextDecoder.h"
  #include "bindings/modules/v8/V8TextEncoder.h"
  #include "bindings/modules/v8/V8WebSocket.h"
  #include "bindings/v8/ExceptionState.h"
  #include "bindings/v8/V8AbstractEventListener.h"
  #include "bindings/v8/V8DOMConfiguration.h"
  #include "bindings/v8/V8EventListenerList.h"
  #include "bindings/v8/V8HiddenValue.h"
  #include "bindings/v8/V8ObjectConstructor.h"
  #include "core/dom/ContextFeatures.h"
  #include "core/dom/Document.h"
  #include "platform/RuntimeEnabledFeatures.h"
  #include "platform/TraceEvent.h"
  #include "wtf/GetPtr.h"
  #include "wtf/RefPtr.h"
  
  namespace WebCore {
  
  static void initializeScriptWrappableForInterface(SharedWorkerGlobalScope* object)
  {
      if (ScriptWrappable::wrapperCanBeStoredInObject(object))
          ScriptWrappable::fromObject(object)->setTypeInfo(&V8SharedWorkerGlobalScope::wrapperTypeInfo);
      else
          ASSERT_NOT_REACHED();
  }
  
  } // namespace WebCore
  
  void webCoreInitializeScriptWrappableForInterface(WebCore::SharedWorkerGlobalScope* object)
  {
      WebCore::initializeScriptWrappableForInterface(object);
  }
  
  namespace WebCore {
  const WrapperTypeInfo V8SharedWorkerGlobalScope::wrapperTypeInfo = { gin::kEmbedderBlink, V8SharedWorkerGlobalScope::domTemplate, V8SharedWorkerGlobalScope::derefObject, 0, V8SharedWorkerGlobalScope::toEventTarget, 0, V8SharedWorkerGlobalScope::installPerContextEnabledMethods, &V8WorkerGlobalScope::wrapperTypeInfo, WrapperTypeObjectPrototype, WillBeGarbageCollectedObject };
  
  namespace SharedWorkerGlobalScopeV8Internal {
  
  template <typename T> void V8_USE(T) { }
  
  static void nameAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
  {
      v8::Handle<v8::Object> holder = info.Holder();
      SharedWorkerGlobalScope* impl = V8SharedWorkerGlobalScope::toNative(holder);
      v8SetReturnValueString(info, impl->name(), info.GetIsolate());
  }
  
  static void nameAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
  {
      TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
      SharedWorkerGlobalScopeV8Internal::nameAttributeGetter(info);
      TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
  }
  
  static void onconnectAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
  {
      v8::Handle<v8::Object> holder = info.Holder();
      SharedWorkerGlobalScope* impl = V8SharedWorkerGlobalScope::toNative(holder);
      EventListener* v8Value = impl->onconnect();
      v8SetReturnValue(info, v8Value ? v8::Handle<v8::Value>(V8AbstractEventListener::cast(v8Value)->getListenerObject(impl->executionContext())) : v8::Handle<v8::Value>(v8::Null(info.GetIsolate())));
  }
  
  static void onconnectAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
  {
      TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
      SharedWorkerGlobalScopeV8Internal::onconnectAttributeGetter(info);
      TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
  }
  
  static void onconnectAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
  {
      v8::Handle<v8::Object> holder = info.Holder();
      SharedWorkerGlobalScope* impl = V8SharedWorkerGlobalScope::toNative(holder);
      moveEventListenerToNewWrapper(holder, impl->onconnect(), v8Value, V8SharedWorkerGlobalScope::eventListenerCacheIndex, info.GetIsolate());
      impl->setOnconnect(V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate));
  }
  
  static void onconnectAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
  {
      TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
      SharedWorkerGlobalScopeV8Internal::onconnectAttributeSetter(v8Value, info);
      TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
  }
  
  static void SharedWorkerGlobalScopeConstructorGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
  {
      v8::Handle<v8::Value> data = info.Data();
      ASSERT(data->IsExternal());
      V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext());
      if (!perContextData)
          return;
      v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::unwrap(data)));
  }
  
  static void SharedWorkerGlobalScopeReplaceableAttributeSetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
  {
      if (info.This()->IsObject())
          v8::Handle<v8::Object>::Cast(info.This())->ForceSet(name, v8Value);
  }
  
  static void SharedWorkerGlobalScopeReplaceableAttributeSetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
  {
      SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetter(name, v8Value, info);
  }
  
  } // namespace SharedWorkerGlobalScopeV8Internal
  
  static const V8DOMConfiguration::AttributeConfiguration V8SharedWorkerGlobalScopeAttributes[] = {
      {"name", SharedWorkerGlobalScopeV8Internal::nameAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
      {"onconnect", SharedWorkerGlobalScopeV8Internal::onconnectAttributeGetterCallback, SharedWorkerGlobalScopeV8Internal::onconnectAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
      {"Blob", SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeConstructorGetter, SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8Blob::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */},
      {"EventSource", SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeConstructorGetter, SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8EventSource::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */},
      {"File", SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeConstructorGetter, SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8File::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */},
      {"FileReader", SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeConstructorGetter, SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8FileReader::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */},
      {"FileReaderSync", SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeConstructorGetter, SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8FileReaderSync::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */},
      {"FormData", SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeConstructorGetter, SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8FormData::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */},
      {"ImageData", SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeConstructorGetter, SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8ImageData::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */},
      {"MessageChannel", SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeConstructorGetter, SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8MessageChannel::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */},
      {"MessageEvent", SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeConstructorGetter, SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8MessageEvent::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */},
      {"SharedWorkerGlobalScope", SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeConstructorGetter, SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8SharedWorkerGlobalScope::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */},
      {"URL", SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeConstructorGetter, SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8URL::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */},
      {"WorkerGlobalScope", SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeConstructorGetter, SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8WorkerGlobalScope::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */},
      {"WorkerLocation", SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeConstructorGetter, SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8WorkerLocation::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */},
      {"WorkerNavigator", SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeConstructorGetter, SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8WorkerNavigator::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */},
      {"XMLHttpRequest", SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeConstructorGetter, SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8XMLHttpRequest::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */},
      {"WebSocket", SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeConstructorGetter, SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8WebSocket::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */},
  };
  
  static void configureV8SharedWorkerGlobalScopeTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
  {
      functionTemplate->ReadOnlyPrototype();
  
      v8::Local<v8::Signature> defaultSignature;
      defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "SharedWorkerGlobalScope", V8WorkerGlobalScope::domTemplate(isolate), V8SharedWorkerGlobalScope::internalFieldCount,
          V8SharedWorkerGlobalScopeAttributes, WTF_ARRAY_LENGTH(V8SharedWorkerGlobalScopeAttributes),
          0, 0,
          0, 0,
          isolate);
      v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
      v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
      if (RuntimeEnabledFeatures::encodingAPIEnabled()) {
          static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
          {"TextDecoder", SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeConstructorGetter, SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8TextDecoder::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */};
          V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate);
      }
      if (RuntimeEnabledFeatures::encodingAPIEnabled()) {
          static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
          {"TextEncoder", SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeConstructorGetter, SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8TextEncoder::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */};
          V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate);
      }
      if (RuntimeEnabledFeatures::networkInformationEnabled()) {
          static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
          {"NetworkInformation", SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeConstructorGetter, SharedWorkerGlobalScopeV8Internal::SharedWorkerGlobalScopeReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8NetworkInformation::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */};
          V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate);
      }
      functionTemplate->SetHiddenPrototype(true);
  
      // Custom toString template
      functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
  }
  
  v8::Handle<v8::FunctionTemplate> V8SharedWorkerGlobalScope::domTemplate(v8::Isolate* isolate)
  {
      return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), configureV8SharedWorkerGlobalScopeTemplate);
  }
  
  bool V8SharedWorkerGlobalScope::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
  {
      return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
  }
  
  v8::Handle<v8::Object> V8SharedWorkerGlobalScope::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
  {
      return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
  }
  
  SharedWorkerGlobalScope* V8SharedWorkerGlobalScope::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
  {
      return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Object>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
  }
  
  EventTarget* V8SharedWorkerGlobalScope::toEventTarget(v8::Handle<v8::Object> object)
  {
      return toNative(object);
  }
  
  v8::Handle<v8::Object> wrap(SharedWorkerGlobalScope* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
  {
      ASSERT(impl);
      ASSERT(!DOMDataStore::containsWrapper<V8SharedWorkerGlobalScope>(impl, isolate));
      return V8SharedWorkerGlobalScope::createWrapper(impl, creationContext, isolate);
  }
  
  v8::Handle<v8::Object> V8SharedWorkerGlobalScope::createWrapper(PassRefPtrWillBeRawPtr<SharedWorkerGlobalScope> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
  {
      ASSERT(impl);
      ASSERT(!DOMDataStore::containsWrapper<V8SharedWorkerGlobalScope>(impl.get(), isolate));
      if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
          const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo();
          // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
          // the same object de-ref functions, though, so use that as the basis of the check.
          RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
      }
  
      v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
      if (UNLIKELY(wrapper.IsEmpty()))
          return wrapper;
  
      installPerContextEnabledProperties(wrapper, impl.get(), isolate);
      V8DOMWrapper::associateObjectWithWrapper<V8SharedWorkerGlobalScope>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
      return wrapper;
  }
  
  void V8SharedWorkerGlobalScope::derefObject(void* object)
  {
  #if !ENABLE(OILPAN)
      fromInternalPointer(object)->deref();
  #endif // !ENABLE(OILPAN)
  }
  
  template<>
  v8::Handle<v8::Value> toV8NoInline(SharedWorkerGlobalScope* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
  {
      return toV8(impl, creationContext, isolate);
  }
  
  } // namespace WebCore
  