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

Side by Side Diff: chrome/browser/resources/tracing/trace_event_importer.js

Issue 9584022: Fix ph error on about:tracing startup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 TraceEventImporter imports TraceEvent-formatted data 6 * @fileoverview TraceEventImporter imports TraceEvent-formatted data
7 * into the provided timeline model. 7 * into the provided timeline model.
8 */ 8 */
9 cr.define('tracing', function() { 9 cr.define('tracing', function() {
10 function ThreadState(tid) { 10 function ThreadState(tid) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // May be encoded JSON. But we dont want to parse it fully yet. 58 // May be encoded JSON. But we dont want to parse it fully yet.
59 // Use a simple heuristic: 59 // Use a simple heuristic:
60 // - eventData that starts with [ are probably trace_event 60 // - eventData that starts with [ are probably trace_event
61 // - eventData that starts with { are probably trace_event 61 // - eventData that starts with { are probably trace_event
62 // May be encoded JSON. Treat files that start with { as importable by us. 62 // May be encoded JSON. Treat files that start with { as importable by us.
63 if (typeof(eventData) === 'string' || eventData instanceof String) { 63 if (typeof(eventData) === 'string' || eventData instanceof String) {
64 return eventData[0] == '{' || eventData[0] == '['; 64 return eventData[0] == '{' || eventData[0] == '[';
65 } 65 }
66 66
67 // Might just be an array of events 67 // Might just be an array of events
68 if (eventData instanceof Array && eventData[0].ph) 68 if (eventData instanceof Array && eventData.length && eventData[0].ph)
69 return true; 69 return true;
70 70
71 // Might be an object with a traceEvents field in it. 71 // Might be an object with a traceEvents field in it.
72 if (eventData.traceEvents) 72 if (eventData.traceEvents)
73 return eventData.traceEvents instanceof Array && 73 return eventData.traceEvents instanceof Array &&
74 eventData.traceEvents[0].ph; 74 eventData.traceEvents[0].ph;
75 75
76 return false; 76 return false;
77 }; 77 };
78 78
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 this.autoCloseOpenSlices(); 317 this.autoCloseOpenSlices();
318 } 318 }
319 }; 319 };
320 320
321 tracing.TimelineModel.registerImporter(TraceEventImporter); 321 tracing.TimelineModel.registerImporter(TraceEventImporter);
322 322
323 return { 323 return {
324 TraceEventImporter: TraceEventImporter 324 TraceEventImporter: TraceEventImporter
325 }; 325 };
326 }); 326 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698