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/core/v8/V8PrivateProperty.h" | 11 #include "bindings/core/v8/V8PrivateProperty.h" |
12 #include "bindings/modules/v8/IDBObserverCallback.h" | 12 #include "bindings/modules/v8/IDBObserverCallback.h" |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
16 void V8IDBObserver::constructorCustom( | 16 void V8IDBObserver::constructorCustom( |
17 const v8::FunctionCallbackInfo<v8::Value>& info) { | 17 const v8::FunctionCallbackInfo<v8::Value>& info) { |
18 ExceptionState exceptionState( | 18 v8::Isolate* isolate = info.GetIsolate(); |
19 info.GetIsolate(), ExceptionState::ConstructionContext, "IDBObserver"); | 19 ExceptionState exceptionState(isolate, ExceptionState::ConstructionContext, |
| 20 "IDBObserver"); |
20 | 21 |
21 if (UNLIKELY(info.Length() < 1)) { | 22 if (UNLIKELY(info.Length() < 1)) { |
22 exceptionState.throwTypeError( | 23 exceptionState.throwTypeError( |
23 ExceptionMessages::notEnoughArguments(1, info.Length())); | 24 ExceptionMessages::notEnoughArguments(1, info.Length())); |
24 return; | 25 return; |
25 } | 26 } |
26 | 27 |
27 v8::Local<v8::Object> wrapper = info.Holder(); | 28 v8::Local<v8::Object> wrapper = info.Holder(); |
28 | 29 |
29 if (!info[0]->IsFunction()) { | 30 if (!info[0]->IsFunction()) { |
(...skipping 14 matching lines...) Expand all Loading... |
44 ScriptState* scriptState = ScriptState::forReceiverObject(info); | 45 ScriptState* scriptState = ScriptState::forReceiverObject(info); |
45 v8::Local<v8::Function> v8Callback = v8::Local<v8::Function>::Cast(info[0]); | 46 v8::Local<v8::Function> v8Callback = v8::Local<v8::Function>::Cast(info[0]); |
46 IDBObserverCallback* callback = | 47 IDBObserverCallback* callback = |
47 IDBObserverCallback::create(scriptState, v8Callback); | 48 IDBObserverCallback::create(scriptState, v8Callback); |
48 IDBObserver* observer = IDBObserver::create(callback); | 49 IDBObserver* observer = IDBObserver::create(callback); |
49 if (exceptionState.hadException()) | 50 if (exceptionState.hadException()) |
50 return; | 51 return; |
51 DCHECK(observer); | 52 DCHECK(observer); |
52 // TODO(bashi): Don't set private property (and remove this custom | 53 // TODO(bashi): Don't set private property (and remove this custom |
53 // constructor) when we can trace correctly. | 54 // constructor) when we can trace correctly. |
54 V8PrivateProperty::getIDBObserverCallback(info.GetIsolate()) | 55 V8PrivateProperty::getIDBObserverCallback(isolate).set(wrapper, v8Callback); |
55 .set(info.GetIsolate()->GetCurrentContext(), wrapper, v8Callback); | 56 v8SetReturnValue(info, V8DOMWrapper::associateObjectWithWrapper( |
56 v8SetReturnValue(info, | 57 isolate, observer, &wrapperTypeInfo, wrapper)); |
57 V8DOMWrapper::associateObjectWithWrapper( | |
58 info.GetIsolate(), observer, &wrapperTypeInfo, wrapper)); | |
59 } | 58 } |
60 | 59 |
61 } // namespace blink | 60 } // namespace blink |
OLD | NEW |