OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! |
| 6 |
| 7 #include "config.h" |
| 8 #include "bindings/core/v8/V8PerformanceObserverCallback.h" |
| 9 |
| 10 #include "bindings/core/v8/ScriptController.h" |
| 11 #include "bindings/core/v8/V8Binding.h" |
| 12 #include "bindings/core/v8/V8PerformanceObserver.h" |
| 13 #include "bindings/core/v8/V8PerformanceObserverEntryList.h" |
| 14 #include "core/dom/ExecutionContext.h" |
| 15 #include "wtf/Assertions.h" |
| 16 |
| 17 namespace blink { |
| 18 |
| 19 V8PerformanceObserverCallback::V8PerformanceObserverCallback(v8::Local<v8::Funct
ion> callback, v8::Local<v8::Object> owner, ScriptState* scriptState) |
| 20 : ActiveDOMCallback(scriptState->executionContext()) |
| 21 , m_callback(scriptState->isolate(), callback) |
| 22 , m_scriptState(scriptState) |
| 23 { |
| 24 V8HiddenValue::setHiddenValue(scriptState->isolate(), owner, V8HiddenValue::
callback(scriptState->isolate()), callback); |
| 25 m_callback.setWeak(this, &setWeakCallback); |
| 26 } |
| 27 |
| 28 V8PerformanceObserverCallback::~V8PerformanceObserverCallback() |
| 29 { |
| 30 } |
| 31 |
| 32 void V8PerformanceObserverCallback::handleEvent(PerformanceObserverEntryList* en
tries, PerformanceObserver* observer) |
| 33 { |
| 34 if (!canInvokeCallback()) |
| 35 return; |
| 36 |
| 37 if (!m_scriptState->contextIsValid()) |
| 38 return; |
| 39 ScriptState::Scope scope(m_scriptState.get()); |
| 40 |
| 41 if (m_callback.isEmpty()) |
| 42 return; |
| 43 v8::Local<v8::Value> observerHandle = toV8(observer, m_scriptState->context(
)->Global(), m_scriptState->isolate()); |
| 44 if (observerHandle.IsEmpty()) { |
| 45 if (!isScriptControllerTerminating()) |
| 46 CRASH(); |
| 47 return; |
| 48 } |
| 49 |
| 50 if (!observerHandle->IsObject()) |
| 51 return; |
| 52 |
| 53 v8::Local<v8::Object> thisObject = v8::Local<v8::Object>::Cast(observerHandl
e); |
| 54 v8::Local<v8::Value> entriesHandle = toV8(entries, m_scriptState->context()-
>Global(), m_scriptState->isolate()); |
| 55 if (entriesHandle.IsEmpty()) { |
| 56 return; |
| 57 } |
| 58 v8::Local<v8::Value> argv[] = { entriesHandle, observerHandle }; |
| 59 |
| 60 v8::TryCatch exceptionCatcher; |
| 61 exceptionCatcher.SetVerbose(true); |
| 62 ScriptController::callFunction(m_scriptState->executionContext(), m_callback
.newLocal(m_scriptState->isolate()), thisObject, 2, argv, m_scriptState->isolate
()); |
| 63 } |
| 64 |
| 65 void V8PerformanceObserverCallback::setWeakCallback(const v8::WeakCallbackInfo<V
8PerformanceObserverCallback>& data) |
| 66 { |
| 67 data.GetParameter()->m_callback.clear(); |
| 68 } |
| 69 |
| 70 DEFINE_TRACE(V8PerformanceObserverCallback) |
| 71 { |
| 72 PerformanceObserverCallback::trace(visitor); |
| 73 ActiveDOMCallback::trace(visitor); |
| 74 } |
| 75 |
| 76 } // namespace blink |
OLD | NEW |