OLD | NEW |
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 Loading... |
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; |
| 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 |
OLD | NEW |