Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Unified Diff: Source/bindings/core/v8/V8PerformanceObserverCallback.cpp

Issue 1198863006: First version of PerformanceObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Code review comments Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/bindings/core/v8/V8PerformanceObserverCallback.cpp
diff --git a/Source/bindings/core/v8/V8PerformanceObserverCallback.cpp b/Source/bindings/core/v8/V8PerformanceObserverCallback.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0212d64f3744944b850730eb1edcba4f39c50ca4
--- /dev/null
+++ b/Source/bindings/core/v8/V8PerformanceObserverCallback.cpp
@@ -0,0 +1,76 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
+
+#include "config.h"
+#include "bindings/core/v8/V8PerformanceObserverCallback.h"
+
+#include "bindings/core/v8/ScriptController.h"
+#include "bindings/core/v8/V8Binding.h"
+#include "bindings/core/v8/V8PerformanceObserver.h"
+#include "bindings/core/v8/V8PerformanceObserverEntryList.h"
+#include "core/dom/ExecutionContext.h"
+#include "wtf/Assertions.h"
+
+namespace blink {
+
+V8PerformanceObserverCallback::V8PerformanceObserverCallback(v8::Local<v8::Function> callback, v8::Local<v8::Object> owner, ScriptState* scriptState)
+ : ActiveDOMCallback(scriptState->executionContext())
+ , m_callback(scriptState->isolate(), callback)
+ , m_scriptState(scriptState)
+{
+ V8HiddenValue::setHiddenValue(scriptState->isolate(), owner, V8HiddenValue::callback(scriptState->isolate()), callback);
+ m_callback.setWeak(this, &setWeakCallback);
+}
+
+V8PerformanceObserverCallback::~V8PerformanceObserverCallback()
+{
+}
+
+void V8PerformanceObserverCallback::handleEvent(PerformanceObserverEntryList* entries, PerformanceObserver* observer)
+{
+ if (!canInvokeCallback())
+ return;
+
+ if (!m_scriptState->contextIsValid())
+ return;
+ ScriptState::Scope scope(m_scriptState.get());
+
+ if (m_callback.isEmpty())
+ return;
+ v8::Local<v8::Value> observerHandle = toV8(observer, m_scriptState->context()->Global(), m_scriptState->isolate());
+ if (observerHandle.IsEmpty()) {
+ if (!isScriptControllerTerminating())
+ CRASH();
+ return;
+ }
+
+ if (!observerHandle->IsObject())
+ return;
+
+ v8::Local<v8::Object> thisObject = v8::Local<v8::Object>::Cast(observerHandle);
+ v8::Local<v8::Value> entriesHandle = toV8(entries, m_scriptState->context()->Global(), m_scriptState->isolate());
+ if (entriesHandle.IsEmpty()) {
+ return;
+ }
+ v8::Local<v8::Value> argv[] = { entriesHandle, observerHandle };
+
+ v8::TryCatch exceptionCatcher;
+ exceptionCatcher.SetVerbose(true);
+ ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), thisObject, 2, argv, m_scriptState->isolate());
+}
+
+void V8PerformanceObserverCallback::setWeakCallback(const v8::WeakCallbackInfo<V8PerformanceObserverCallback>& data)
+{
+ data.GetParameter()->m_callback.clear();
+}
+
+DEFINE_TRACE(V8PerformanceObserverCallback)
+{
+ PerformanceObserverCallback::trace(visitor);
+ ActiveDOMCallback::trace(visitor);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698