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

Unified Diff: Source/bindings/core/v8/custom/V8PerformanceObserverCustom.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/custom/V8PerformanceObserverCustom.cpp
diff --git a/Source/bindings/core/v8/custom/V8PerformanceObserverCustom.cpp b/Source/bindings/core/v8/custom/V8PerformanceObserverCustom.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..83b306aed28d3b87a7a9181503fff11cf9e8844b
--- /dev/null
+++ b/Source/bindings/core/v8/custom/V8PerformanceObserverCustom.cpp
@@ -0,0 +1,51 @@
+// Copyright 2015 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.
+
+#include "config.h"
+#include "bindings/core/v8/V8PerformanceObserver.h"
+
+#include "bindings/core/v8/ExceptionMessages.h"
+#include "bindings/core/v8/ExceptionState.h"
+#include "bindings/core/v8/V8Binding.h"
+#include "bindings/core/v8/V8DOMWrapper.h"
+#include "bindings/core/v8/V8GCController.h"
+#include "bindings/core/v8/V8Performance.h"
+#include "bindings/core/v8/V8PerformanceObserverCallback.h"
+#include "core/timing/DOMWindowPerformance.h"
+#include "core/timing/PerformanceObserver.h"
+
+namespace blink {
+
+void V8PerformanceObserver::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ if (UNLIKELY(info.Length() < 1)) {
+ V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(info.GetIsolate(), "createPerformanceObserver", "Performance", 1, info.Length()), info.GetIsolate());
+ return;
+ }
+
+ v8::Local<v8::Object> wrapper = info.Holder();
+
+ Performance* performance = nullptr;
+ DOMWindow* window = toDOMWindow(wrapper->CreationContext());
+ if (!window) {
+ V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("createPerformanceObserver", "Performance", "No \"window\" in current context."));
+ return;
+ }
+ performance = DOMWindowPerformance::performance(*window);
+ ASSERT(performance);
+
+ PerformanceObserverCallback* callback;
+ {
+ if (info.Length() <= 0 || !info[0]->IsFunction()) {
+ V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("createPerformanceObserver", "Performance", "The callback provided as parameter 1 is not a function."));
+ return;
+ }
+ callback = V8PerformanceObserverCallback::create(v8::Local<v8::Function>::Cast(info[0]), wrapper, ScriptState::current(info.GetIsolate()));
+ }
+ PerformanceObserver* observer = PerformanceObserver::create(performance, callback);
+
+ v8SetReturnValue(info, V8DOMWrapper::associateObjectWithWrapper(info.GetIsolate(), observer, &wrapperTypeInfo, wrapper));
+}
+
+} // namespace blink
« no previous file with comments | « Source/bindings/core/v8/V8PerformanceObserverCallback.cpp ('k') | Source/bindings/core/v8/custom/custom.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698