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

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: remove Inspector calls and update LayoutTest. 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)
esprehn 2015/09/09 22:41:40 Throw if there's no window? There should always be
MikeB 2015/09/10 19:53:01 Done.
32 performance = DOMWindowPerformance::performance(*window);
esprehn 2015/09/09 22:41:40 ASSERT(performance) ?
MikeB 2015/09/10 19:53:01 Done.
33
34 PerformanceObserverCallback* callback;
35 {
36 if (info.Length() <= 0 || !info[0]->IsFunction()) {
37 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessage s::failedToExecute("createPerformanceObserver", "Performance", "The callback pro vided as parameter 1 is not a function."));
38 return;
39 }
40 callback = V8PerformanceObserverCallback::create(v8::Local<v8::Function> ::Cast(info[0]), wrapper, ScriptState::current(info.GetIsolate()));
41 }
42 PerformanceObserver* observer = PerformanceObserver::create(performance, cal lback);
43
44 v8SetReturnValue(info, V8DOMWrapper::associateObjectWithWrapper(info.GetIsol ate(), observer, &wrapperTypeInfo, wrapper));
45 }
46
47 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698