| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/core/v8/V8PerformanceObserver.h" | 5 #include "bindings/core/v8/V8PerformanceObserver.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionMessages.h" | 7 #include "bindings/core/v8/ExceptionMessages.h" |
| 8 #include "bindings/core/v8/PerformanceObserverCallback.h" | 8 #include "bindings/core/v8/PerformanceObserverCallback.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 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 Performance* performance = nullptr; | 34 Performance* performance = nullptr; |
| 35 LocalDOMWindow* window = ToLocalDOMWindow(wrapper->CreationContext()); | 35 LocalDOMWindow* window = ToLocalDOMWindow(wrapper->CreationContext()); |
| 36 if (!window) { | 36 if (!window) { |
| 37 V8ThrowException::ThrowTypeError( | 37 V8ThrowException::ThrowTypeError( |
| 38 isolate, ExceptionMessages::FailedToConstruct( | 38 isolate, ExceptionMessages::FailedToConstruct( |
| 39 "PerformanceObserver", "No 'window' in current context.")); | 39 "PerformanceObserver", "No 'window' in current context.")); |
| 40 return; | 40 return; |
| 41 } | 41 } |
| 42 performance = DOMWindowPerformance::performance(*window); | 42 performance = DOMWindowPerformance::performance(*window); |
| 43 ASSERT(performance); | 43 DCHECK(performance); |
| 44 | 44 |
| 45 if (info.Length() <= 0 || !info[0]->IsFunction()) { | 45 if (info.Length() <= 0 || !info[0]->IsFunction()) { |
| 46 V8ThrowException::ThrowTypeError( | 46 V8ThrowException::ThrowTypeError( |
| 47 isolate, | 47 isolate, |
| 48 ExceptionMessages::FailedToConstruct( | 48 ExceptionMessages::FailedToConstruct( |
| 49 "PerformanceObserver", | 49 "PerformanceObserver", |
| 50 "The callback provided as parameter 1 is not a function.")); | 50 "The callback provided as parameter 1 is not a function.")); |
| 51 return; | 51 return; |
| 52 } | 52 } |
| 53 ScriptState* script_state = ScriptState::ForReceiverObject(info); | 53 ScriptState* script_state = ScriptState::ForReceiverObject(info); |
| 54 v8::Local<v8::Function> v8_callback = v8::Local<v8::Function>::Cast(info[0]); | 54 v8::Local<v8::Function> v8_callback = v8::Local<v8::Function>::Cast(info[0]); |
| 55 PerformanceObserverCallback* callback = | 55 PerformanceObserverCallback* callback = |
| 56 PerformanceObserverCallback::Create(script_state, v8_callback); | 56 PerformanceObserverCallback::Create(script_state, v8_callback); |
| 57 | 57 |
| 58 PerformanceObserver* observer = PerformanceObserver::Create( | 58 PerformanceObserver* observer = PerformanceObserver::Create( |
| 59 CurrentExecutionContext(isolate), performance, callback); | 59 CurrentExecutionContext(isolate), performance, callback); |
| 60 | 60 |
| 61 // TODO(bashi): Don't set private property (and remove this custom | 61 // TODO(bashi): Don't set private property (and remove this custom |
| 62 // constructor) when we can trace correctly. See crbug.com/468240. | 62 // constructor) when we can trace correctly. See crbug.com/468240. |
| 63 V8PrivateProperty::GetPerformanceObserverCallback(isolate).Set(wrapper, | 63 V8PrivateProperty::GetPerformanceObserverCallback(isolate).Set(wrapper, |
| 64 v8_callback); | 64 v8_callback); |
| 65 V8SetReturnValue(info, V8DOMWrapper::AssociateObjectWithWrapper( | 65 V8SetReturnValue(info, V8DOMWrapper::AssociateObjectWithWrapper( |
| 66 isolate, observer, &wrapperTypeInfo, wrapper)); | 66 isolate, observer, &wrapperTypeInfo, wrapper)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace blink | 69 } // namespace blink |
| OLD | NEW |