| Index: Source/bindings/v8/custom/V8LockManagerCustom.cpp
|
| diff --git a/Source/bindings/v8/custom/V8MutationObserverCustom.cpp b/Source/bindings/v8/custom/V8LockManagerCustom.cpp
|
| similarity index 55%
|
| copy from Source/bindings/v8/custom/V8MutationObserverCustom.cpp
|
| copy to Source/bindings/v8/custom/V8LockManagerCustom.cpp
|
| index 18408793d7e62ed60541211ba0eecb8abd8e32b9..3333947dcd3617e837aaad563d6648b0a416ead8 100644
|
| --- a/Source/bindings/v8/custom/V8MutationObserverCustom.cpp
|
| +++ b/Source/bindings/v8/custom/V8LockManagerCustom.cpp
|
| @@ -1,5 +1,5 @@
|
| /*
|
| - * Copyright (C) 2011 Google Inc. All rights reserved.
|
| + * Copyright (C) 2014 Google Inc. All rights reserved.
|
| *
|
| * Redistribution and use in source and binary forms, with or without
|
| * modification, are permitted provided that the following conditions are
|
| @@ -29,52 +29,56 @@
|
| */
|
|
|
| #include "config.h"
|
| -#include "V8MutationObserver.h"
|
| +#include "V8LockManager.h"
|
|
|
| #include "bindings/v8/ExceptionMessages.h"
|
| #include "bindings/v8/ExceptionState.h"
|
| +#include "bindings/v8/SerializedScriptValue.h"
|
| #include "bindings/v8/V8Binding.h"
|
| -#include "bindings/v8/V8DOMWrapper.h"
|
| -#include "bindings/v8/V8GCController.h"
|
| -#include "bindings/v8/V8MutationCallback.h"
|
| -#include "core/dom/MutationObserver.h"
|
| +#include "bindings/v8/V8BindingMacros.h"
|
| +#include "core/dom/MessagePort.h"
|
| +#include "wtf/ArrayBuffer.h"
|
|
|
| namespace WebCore {
|
|
|
| -void V8MutationObserver::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8LockManager::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| - ExceptionState exceptionState(ExceptionState::ConstructionContext, "MutationObserver", info.Holder(), info.GetIsolate());
|
| - if (info.Length() < 1) {
|
| - exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
|
| - exceptionState.throwIfNeeded();
|
| - return;
|
| - }
|
| + ExecutionContext* context = currentExecutionContext(info.GetIsolate());
|
|
|
| - v8::Local<v8::Value> arg = info[0];
|
| - if (!arg->IsFunction()) {
|
| - exceptionState.throwTypeError("Callback argument must be a function");
|
| - exceptionState.throwIfNeeded();
|
| - return;
|
| - }
|
| + RefPtr<LockManager> obj = LockManager::create(context);
|
|
|
| - ExecutionContext* context = currentExecutionContext(info.GetIsolate());
|
| - v8::Handle<v8::Object> wrapper = info.Holder();
|
| + v8::Local<v8::Object> wrapper = info.Holder();
|
|
|
| - OwnPtr<MutationCallback> callback = V8MutationCallback::create(v8::Handle<v8::Function>::Cast(arg), context, wrapper, info.GetIsolate());
|
| - RefPtr<MutationObserver> observer = MutationObserver::create(callback.release());
|
| + // TODO V8HiddenValue::setHiddenValue any fields.
|
|
|
| - V8DOMWrapper::associateObjectWithWrapper<V8MutationObserver>(observer.release(), &wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
|
| + V8DOMWrapper::associateObjectWithWrapper<V8LockManager>(obj.release(), &wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
|
| info.GetReturnValue().Set(wrapper);
|
| }
|
|
|
| -void V8MutationObserver::visitDOMWrapper(void* object, const v8::Persistent<v8::Object>& wrapper, v8::Isolate* isolate)
|
| +void V8LockManager::lockMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| - MutationObserver* observer = static_cast<MutationObserver*>(object);
|
| - HashSet<Node*> observedNodes = observer->getObservedNodes();
|
| - for (HashSet<Node*>::iterator it = observedNodes.begin(); it != observedNodes.end(); ++it) {
|
| - v8::UniqueId id(reinterpret_cast<intptr_t>(V8GCController::opaqueRootForGC(*it, isolate)));
|
| - isolate->SetReferenceFromGroup(id, wrapper);
|
| + ExceptionState exceptionState(ExceptionState::ExecutionContext, "lock", "LockManager", info.Holder(), info.GetIsolate());
|
| + if (UNLIKELY(info.Length() < 1)) {
|
| + exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
|
| + exceptionState.throwIfNeeded();
|
| + return;
|
| + }
|
| + LockManager* imp = V8LockManager::toNative(info.Holder());
|
| + TONATIVE_VOID_EXCEPTIONSTATE(uint32_t, uid, toUInt32(info[0], exceptionState), exceptionState);
|
| + imp->lock(uid);
|
| +}
|
| +
|
| +void V8LockManager::unlockMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +{
|
| + ExceptionState exceptionState(ExceptionState::ExecutionContext, "unlock", "LockManager", info.Holder(), info.GetIsolate());
|
| + if (UNLIKELY(info.Length() < 1)) {
|
| + exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
|
| + exceptionState.throwIfNeeded();
|
| + return;
|
| }
|
| + LockManager* imp = V8LockManager::toNative(info.Holder());
|
| + TONATIVE_VOID_EXCEPTIONSTATE(uint32_t, uid, toUInt32(info[0], exceptionState), exceptionState);
|
| + imp->unlock(uid);
|
| }
|
|
|
| } // namespace WebCore
|
|
|