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

Side by Side Diff: Source/core/timing/PerformanceEntry.cpp

Issue 1198863006: First version of PerformanceObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Switch from microtask to timer for firing events. Created 5 years, 5 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
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 23 matching lines...) Expand all
34 #include "bindings/core/v8/ScriptValue.h" 34 #include "bindings/core/v8/ScriptValue.h"
35 #include "bindings/core/v8/V8ObjectBuilder.h" 35 #include "bindings/core/v8/V8ObjectBuilder.h"
36 36
37 namespace blink { 37 namespace blink {
38 38
39 PerformanceEntry::PerformanceEntry(const String& name, const String& entryType, double startTime, double finishTime) 39 PerformanceEntry::PerformanceEntry(const String& name, const String& entryType, double startTime, double finishTime)
40 : m_name(name) 40 : m_name(name)
41 , m_entryType(entryType) 41 , m_entryType(entryType)
42 , m_startTime(startTime) 42 , m_startTime(startTime)
43 , m_duration(finishTime - startTime) 43 , m_duration(finishTime - startTime)
44 , m_entryTypeEnum(toEntryTypeEnum(entryType))
44 { 45 {
45 } 46 }
46 47
47 PerformanceEntry::~PerformanceEntry() 48 PerformanceEntry::~PerformanceEntry()
48 { 49 {
49 } 50 }
50 51
51 String PerformanceEntry::name() const 52 String PerformanceEntry::name() const
52 { 53 {
53 return m_name; 54 return m_name;
54 } 55 }
55 56
56 String PerformanceEntry::entryType() const 57 String PerformanceEntry::entryType() const
57 { 58 {
58 return m_entryType; 59 return m_entryType;
59 } 60 }
60 61
61 double PerformanceEntry::startTime() const 62 double PerformanceEntry::startTime() const
62 { 63 {
63 return m_startTime; 64 return m_startTime;
64 } 65 }
65 66
66 double PerformanceEntry::duration() const 67 double PerformanceEntry::duration() const
67 { 68 {
68 return m_duration; 69 return m_duration;
69 } 70 }
70 71
72 PerformanceEntry::EntryType PerformanceEntry::toEntryTypeEnum(const String& entr yType)
73 {
74 if (equalIgnoringCase(entryType, "composite"))
75 return Composite;
76 if (equalIgnoringCase(entryType, "mark"))
77 return Mark;
78 if (equalIgnoringCase(entryType, "measure"))
79 return Measure;
80 if (equalIgnoringCase(entryType, "render"))
81 return Render;
82 if (equalIgnoringCase(entryType, "resource"))
83 return Resource;
esprehn 2015/07/24 08:23:12 This is fine for now, but we'd probably use a sort
84 return Invalid;
85 }
86
71 ScriptValue PerformanceEntry::toJSONForBinding(ScriptState* scriptState) const 87 ScriptValue PerformanceEntry::toJSONForBinding(ScriptState* scriptState) const
72 { 88 {
73 V8ObjectBuilder result(scriptState); 89 V8ObjectBuilder result(scriptState);
74 result.addString("name", name()); 90 result.addString("name", name());
75 result.addString("entryType", entryType()); 91 result.addString("entryType", entryType());
76 result.addNumber("startTime", startTime()); 92 result.addNumber("startTime", startTime());
77 result.addNumber("duration", duration()); 93 result.addNumber("duration", duration());
78 return result.scriptValue(); 94 return result.scriptValue();
79 } 95 }
80 96
81 } // namespace blink 97 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698