Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bindings/modules/v8/V8IDBObserver.h" | 5 #include "bindings/modules/v8/V8IDBObserver.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionMessages.h" | 7 #include "bindings/core/v8/ExceptionMessages.h" |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "bindings/core/v8/V8Binding.h" | 9 #include "bindings/core/v8/V8Binding.h" |
| 10 #include "bindings/core/v8/V8DOMWrapper.h" | 10 #include "bindings/core/v8/V8DOMWrapper.h" |
| 11 #include "bindings/modules/v8/V8IDBObserverCallback.h" | 11 #include "bindings/core/v8/V8PrivateProperty.h" |
| 12 #include "bindings/modules/v8/IDBObserverCallback.h" | |
| 12 #include "bindings/modules/v8/V8IDBObserverInit.h" | 13 #include "bindings/modules/v8/V8IDBObserverInit.h" |
| 13 | 14 |
| 14 namespace blink { | 15 namespace blink { |
| 15 | 16 |
| 16 void V8IDBObserver::constructorCustom( | 17 void V8IDBObserver::constructorCustom( |
| 17 const v8::FunctionCallbackInfo<v8::Value>& info) { | 18 const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 18 ExceptionState exceptionState( | 19 ExceptionState exceptionState( |
| 19 info.GetIsolate(), ExceptionState::ConstructionContext, "IDBObserver"); | 20 info.GetIsolate(), ExceptionState::ConstructionContext, "IDBObserver"); |
| 20 | 21 |
| 21 if (UNLIKELY(info.Length() < 1)) { | 22 if (UNLIKELY(info.Length() < 1)) { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 37 exceptionState.throwTypeError("parameter 2 ('options') is not an object."); | 38 exceptionState.throwTypeError("parameter 2 ('options') is not an object."); |
| 38 return; | 39 return; |
| 39 } | 40 } |
| 40 | 41 |
| 41 IDBObserverInit idbObserverInit; | 42 IDBObserverInit idbObserverInit; |
| 42 V8IDBObserverInit::toImpl(info.GetIsolate(), info[1], idbObserverInit, | 43 V8IDBObserverInit::toImpl(info.GetIsolate(), info[1], idbObserverInit, |
| 43 exceptionState); | 44 exceptionState); |
| 44 if (exceptionState.hadException()) | 45 if (exceptionState.hadException()) |
| 45 return; | 46 return; |
| 46 | 47 |
| 48 v8::Local<v8::Function> v8Callback = v8::Local<v8::Function>::Cast(info[0]); | |
| 47 IDBObserverCallback* callback = | 49 IDBObserverCallback* callback = |
| 48 new V8IDBObserverCallback(v8::Local<v8::Function>::Cast(info[0]), wrapper, | 50 IDBObserverCallback::create(info.GetIsolate(), v8Callback); |
| 49 ScriptState::current(info.GetIsolate())); | 51 IDBObserver* observer = IDBObserver::create( |
| 50 IDBObserver* observer = IDBObserver::create(*callback, idbObserverInit); | 52 ScriptState::forReceiverObject(info), callback, idbObserverInit); |
| 51 if (exceptionState.hadException()) | 53 if (exceptionState.hadException()) |
| 52 return; | 54 return; |
| 53 DCHECK(observer); | 55 DCHECK(observer); |
| 56 // TODO(bashi): Do we need this? | |
| 57 V8PrivateProperty::getIDBObserverCallback(info.GetIsolate()) | |
|
bashi
2016/10/07 07:07:26
Auto-generated IDBObserverCallback calls setPhanto
haraken
2016/10/07 07:23:35
The point is that we need to add a strong referenc
bashi
2016/10/07 07:28:38
OK, let me ask another question. Who/when to call
| |
| 58 .set(info.GetIsolate()->GetCurrentContext(), wrapper, v8Callback); | |
| 54 v8SetReturnValue(info, | 59 v8SetReturnValue(info, |
| 55 V8DOMWrapper::associateObjectWithWrapper( | 60 V8DOMWrapper::associateObjectWithWrapper( |
| 56 info.GetIsolate(), observer, &wrapperTypeInfo, wrapper)); | 61 info.GetIsolate(), observer, &wrapperTypeInfo, wrapper)); |
| 57 } | 62 } |
| 58 | 63 |
| 59 } // namespace blink | 64 } // namespace blink |
| OLD | NEW |