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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "bindings/core/v8/V8PerformanceObserver.h"
7
8 #include "bindings/core/v8/ExceptionMessages.h"
9 #include "bindings/core/v8/ExceptionState.h"
10 #include "bindings/core/v8/V8Binding.h"
11 #include "bindings/core/v8/V8DOMWrapper.h"
12 #include "bindings/core/v8/V8GCController.h"
13 #include "bindings/core/v8/V8Performance.h"
14 #include "bindings/core/v8/V8PerformanceObserverCallback.h"
15 #include "core/timing/DOMWindowPerformance.h"
16 #include "core/timing/PerformanceObserver.h"
17
18 namespace blink {
19
20 void V8PerformanceObserver::constructorCustom(const v8::FunctionCallbackInfo<v8: :Value>& info)
21 {
22 if (UNLIKELY(info.Length() < 1)) {
23 V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(in fo.GetIsolate(), "createPerformanceObserver", "Performance", 1, info.Length()), info.GetIsolate());
24 return;
25 }
26
27 v8::Local<v8::Object> wrapper = info.Holder();
28
29 Performance* performance = nullptr;
30 DOMWindow* window = toDOMWindow(wrapper->CreationContext());
31 if (!window) {
32 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::f ailedToExecute("createPerformanceObserver", "Performance", "No \"window\" in cur rent context."));
33 return;
34 }
35 performance = DOMWindowPerformance::performance(*window);
36 ASSERT(performance);
37
38 PerformanceObserverCallback* callback;
39 {
40 if (info.Length() <= 0 || !info[0]->IsFunction()) {
41 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessage s::failedToExecute("createPerformanceObserver", "Performance", "The callback pro vided as parameter 1 is not a function."));
42 return;
43 }
44 callback = V8PerformanceObserverCallback::create(v8::Local<v8::Function> ::Cast(info[0]), wrapper, ScriptState::current(info.GetIsolate()));
45 }
46 PerformanceObserver* observer = PerformanceObserver::create(performance, cal lback);
47
48 v8SetReturnValue(info, V8DOMWrapper::associateObjectWithWrapper(info.GetIsol ate(), observer, &wrapperTypeInfo, wrapper));
49 }
50
51 } // namespace blink
OLDNEW
« 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