| 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" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 exceptionState.throwTypeError("parameter 2 ('options') is not an object."); | 38 exceptionState.throwTypeError("parameter 2 ('options') is not an object."); |
| 39 return; | 39 return; |
| 40 } | 40 } |
| 41 | 41 |
| 42 IDBObserverInit idbObserverInit; | 42 IDBObserverInit idbObserverInit; |
| 43 V8IDBObserverInit::toImpl(info.GetIsolate(), info[1], idbObserverInit, | 43 V8IDBObserverInit::toImpl(info.GetIsolate(), info[1], idbObserverInit, |
| 44 exceptionState); | 44 exceptionState); |
| 45 if (exceptionState.hadException()) | 45 if (exceptionState.hadException()) |
| 46 return; | 46 return; |
| 47 | 47 |
| 48 ScriptState* scriptState = ScriptState::forReceiverObject(info); |
| 48 v8::Local<v8::Function> v8Callback = v8::Local<v8::Function>::Cast(info[0]); | 49 v8::Local<v8::Function> v8Callback = v8::Local<v8::Function>::Cast(info[0]); |
| 49 IDBObserverCallback* callback = | 50 IDBObserverCallback* callback = |
| 50 IDBObserverCallback::create(info.GetIsolate(), v8Callback); | 51 IDBObserverCallback::create(scriptState, v8Callback); |
| 51 IDBObserver* observer = IDBObserver::create( | 52 IDBObserver* observer = IDBObserver::create(callback, idbObserverInit); |
| 52 ScriptState::forReceiverObject(info), callback, idbObserverInit); | |
| 53 if (exceptionState.hadException()) | 53 if (exceptionState.hadException()) |
| 54 return; | 54 return; |
| 55 DCHECK(observer); | 55 DCHECK(observer); |
| 56 // TODO(bashi): Don't set private property (and remove this custom | 56 // TODO(bashi): Don't set private property (and remove this custom |
| 57 // constructor) when we can call setWrapperReference() correctly. | 57 // constructor) when we can call setWrapperReference() correctly. |
| 58 V8PrivateProperty::getIDBObserverCallback(info.GetIsolate()) | 58 V8PrivateProperty::getIDBObserverCallback(info.GetIsolate()) |
| 59 .set(info.GetIsolate()->GetCurrentContext(), wrapper, v8Callback); | 59 .set(info.GetIsolate()->GetCurrentContext(), wrapper, v8Callback); |
| 60 v8SetReturnValue(info, | 60 v8SetReturnValue(info, |
| 61 V8DOMWrapper::associateObjectWithWrapper( | 61 V8DOMWrapper::associateObjectWithWrapper( |
| 62 info.GetIsolate(), observer, &wrapperTypeInfo, wrapper)); | 62 info.GetIsolate(), observer, &wrapperTypeInfo, wrapper)); |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace blink | 65 } // namespace blink |
| OLD | NEW |