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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 base.require('model.layer_tree_host_impl'); | 7 base.require('model.layer_tree_host_impl'); |
8 | 8 |
9 base.exportTo('ccfv', function() { | 9 base.exportTo('ccfv', function() { |
10 | 10 |
11 function unquoteIfNeeded(val) { | 11 function unquoteIfNeeded(val) { |
| 12 if (typeof val !== 'string') |
| 13 return val; |
12 if (val[0] == '{' && val[val.length - 1] == '}') { | 14 if (val[0] == '{' && val[val.length - 1] == '}') { |
13 return JSON.parse(val); | 15 return JSON.parse(val); |
14 } else { | 16 } else { |
15 return val; | 17 return val; |
16 } | 18 } |
17 } | 19 } |
18 | 20 |
19 /** | 21 /** |
20 * A generic container for data from a cc trace. | 22 * A generic container for data from a cc trace. |
21 * | 23 * |
(...skipping 26 matching lines...) Expand all Loading... |
48 | 50 |
49 var events = trace.traceEvents; | 51 var events = trace.traceEvents; |
50 for (var i = 0; i < events.length; i++) { | 52 for (var i = 0; i < events.length; i++) { |
51 var event = events[i]; | 53 var event = events[i]; |
52 if (event.name == 'Frame') | 54 if (event.name == 'Frame') |
53 this.handleFrameEvent(event); | 55 this.handleFrameEvent(event); |
54 } | 56 } |
55 }, | 57 }, |
56 | 58 |
57 handleFrameEvent: function(event) { | 59 handleFrameEvent: function(event) { |
58 if (typeof event.args.frame !== 'string') | 60 if (event.args.frame === 'undefined') |
59 throw new Error('Expected Frame to have args.frame of type string.'); | 61 throw new Error('Expected Frame to have args.frame of type string.'); |
60 var frameData = unquoteIfNeeded(event.args.frame); | 62 var frameData = unquoteIfNeeded(event.args.frame); |
61 | 63 |
62 var lthiID; | 64 var lthiID; |
63 if (frameData.lthi_id === undefined) { | 65 if (frameData.lthi_id === undefined) { |
64 // Old versions used compositor_instance instead of lthiID. | 66 // Old versions used compositor_instance instead of lthiID. |
65 if (frameData.compositor_instance === undefined) | 67 if (frameData.compositor_instance === undefined) |
66 throw new Error('Expected Frame to have a lthi_id field.'); | 68 throw new Error('Expected Frame to have a lthi_id field.'); |
67 lthiID = frameData.compositor_instance; | 69 lthiID = frameData.compositor_instance; |
68 } else { | 70 } else { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 tile.managedState = tileData.managed_state; | 108 tile.managedState = tileData.managed_state; |
107 } | 109 } |
108 }; | 110 }; |
109 | 111 |
110 | 112 |
111 return { | 113 return { |
112 Model: Model, | 114 Model: Model, |
113 } | 115 } |
114 }); | 116 }); |
115 | 117 |
OLD | NEW |