Chromium Code Reviews| Index: third_party/WebKit/Source/bindings/modules/v8/custom/V8IDBObserverCustom.cpp |
| diff --git a/third_party/WebKit/Source/bindings/modules/v8/custom/V8IDBObserverCustom.cpp b/third_party/WebKit/Source/bindings/modules/v8/custom/V8IDBObserverCustom.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c2ea1d8c200ebdaa9aa849f400c18c749e2df8d5 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/bindings/modules/v8/custom/V8IDBObserverCustom.cpp |
| @@ -0,0 +1,50 @@ |
| +// Copyright 2016 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 "bindings/modules/v8/V8IDBObserver.h" |
| + |
| +#include "bindings/core/v8/ExceptionMessages.h" |
| +#include "bindings/core/v8/ExceptionState.h" |
| +#include "bindings/core/v8/V8Binding.h" |
| +#include "bindings/core/v8/V8DOMWrapper.h" |
| +#include "bindings/core/v8/V8GCController.h" |
| +#include "bindings/modules/v8/V8IDBObserverCallback.h" |
| +#include "bindings/modules/v8/V8IDBObserverInit.h" |
| + |
| +namespace blink { |
| + |
| +void V8IDBObserver::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + if (UNLIKELY(info.Length() < 1)) { |
| + V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(info.GetIsolate(), "createIDBObserver", "IDB", 1, info.Length()), info.GetIsolate()); |
|
dmurph
2016/06/02 23:48:37
s/"IDB"/"IDBObserver"/ here an below.
Marijn Kruisselbrink
2016/06/02 23:51:24
I think this should be createMinimumArityTypeError
palakj1
2016/06/03 01:21:52
Done
|
| + return; |
| + } |
| + |
| + v8::Local<v8::Object> wrapper = info.Holder(); |
| + |
| + if (!info[0]->IsFunction()) { |
| + V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("createIDBObserver", "IDB", "The callback provided as parameter 1 is not a function.")); |
|
Marijn Kruisselbrink
2016/06/02 23:51:24
All these other failedToExecute methods also seem
palakj1
2016/06/03 01:21:52
Changes made.
|
| + return; |
| + } |
| + |
| + if (info.Length() > 1 && !isUndefinedOrNull(info[1]) && !info[1]->IsObject()) { |
| + V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("createIDBObserver", "IDB", "IDBObserverInit (parameter 2) is not an object.")); |
| + return; |
| + } |
| + |
| + IDBObserverInit idbObserverInit; |
| + ExceptionState exceptionState(ExceptionState::ConstructionContext, "IDB", info.Holder(), info.GetIsolate()); |
|
Marijn Kruisselbrink
2016/06/02 23:51:24
Here also "IDB" should be "IDBObserver" to get cor
palakj1
2016/06/03 01:21:52
Done
|
| + V8IDBObserverInit::toImpl(info.GetIsolate(), info[1], idbObserverInit, exceptionState); |
| + if (exceptionState.throwIfNeeded()) |
| + return; |
| + |
| + IDBObserverCallback* callback = new V8IDBObserverCallback(v8::Local<v8::Function>::Cast(info[0]), wrapper, ScriptState::current(info.GetIsolate())); |
| + IDBObserver* observer = IDBObserver::create(*callback, idbObserverInit); |
| + if (exceptionState.throwIfNeeded()) |
| + return; |
| + ASSERT(observer); |
| + v8SetReturnValue(info, V8DOMWrapper::associateObjectWithWrapper(info.GetIsolate(), observer, &wrapperTypeInfo, wrapper)); |
| +} |
| + |
| +} // namespace blink |