OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * LogGroupEntry is a wrapper around log entries, which makes it easier to | 7 * LogGroupEntry is a wrapper around log entries, which makes it easier to |
8 * find the corresponding start/end of events. | 8 * find the corresponding start/end of events. |
9 * | 9 * |
10 * This is used internally by the log and timeline views to pretty print | 10 * This is used internally by the log and timeline views to pretty print |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 for (var i = 0; i < origEntries.length; ++i) { | 62 for (var i = 0; i < origEntries.length; ++i) { |
63 var origEntry = origEntries[i]; | 63 var origEntry = origEntries[i]; |
64 | 64 |
65 var groupEntry = new LogGroupEntry(origEntry, i); | 65 var groupEntry = new LogGroupEntry(origEntry, i); |
66 groupedEntries.push(groupEntry); | 66 groupedEntries.push(groupEntry); |
67 | 67 |
68 // If this is the end of an event, match it to the start. | 68 // If this is the end of an event, match it to the start. |
69 if (groupEntry.isEnd()) { | 69 if (groupEntry.isEnd()) { |
70 // Walk up the parent stack to find the corresponding BEGIN for this | 70 // Walk up the parent stack to find the corresponding BEGIN for this |
71 // END. | 71 // END. |
72 var parentIndex = | 72 var parentIndex = findParentIndex(parentStack, groupEntry.orig.type); |
73 findParentIndex(parentStack, groupEntry.orig.type); | |
74 | 73 |
75 if (parentIndex == -1) { | 74 if (parentIndex == -1) { |
76 // Unmatched end. | 75 // Unmatched end. |
77 } else { | 76 } else { |
78 groupEntry.begin = parentStack[parentIndex]; | 77 groupEntry.begin = parentStack[parentIndex]; |
79 | 78 |
80 // Consider this as the terminator for all open BEGINs up until | 79 // Consider this as the terminator for all open BEGINs up until |
81 // parentIndex. | 80 // parentIndex. |
82 while (parentIndex < parentStack.length) { | 81 while (parentIndex < parentStack.length) { |
83 var p = parentStack.pop(); | 82 var p = parentStack.pop(); |
84 p.end = groupEntry; | 83 p.end = groupEntry; |
85 } | 84 } |
86 } | 85 } |
87 } | 86 } |
88 | 87 |
89 // Inherit the current parent. | 88 // Inherit the current parent. |
90 if (parentStack.length > 0) | 89 if (parentStack.length > 0) |
91 groupEntry.parentEntry = parentStack[parentStack.length - 1]; | 90 groupEntry.parentEntry = parentStack[parentStack.length - 1]; |
92 | 91 |
93 if (groupEntry.isBegin()) | 92 if (groupEntry.isBegin()) |
94 parentStack.push(groupEntry); | 93 parentStack.push(groupEntry); |
95 } | 94 } |
96 | 95 |
97 return groupedEntries; | 96 return groupedEntries; |
98 }; | 97 }; |
99 | 98 |
100 return LogGroupEntry; | 99 return LogGroupEntry; |
101 })(); | 100 })(); |
OLD | NEW |