Commit a6ecf5fd authored by nduca@chromium.org's avatar nduca@chromium.org

Fix ph error on about:tracnig startup.

BUG=116189


Review URL: http://codereview.chromium.org/9584022

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124789 0039d316-1c4b-4281-b951-d872f2087c98
parent ca9bc12c
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -502,7 +502,28 @@ cr.define('tracing', function() { ...@@ -502,7 +502,28 @@ cr.define('tracing', function() {
*/ */
TimelineModel.registerImporter = function(importerConstructor) { TimelineModel.registerImporter = function(importerConstructor) {
importerConstructors.push(importerConstructor); importerConstructors.push(importerConstructor);
};
function TimelineModelEmptyImporter(events) {
};
TimelineModelEmptyImporter.canImport = function(eventData) {
if (eventData instanceof Array && eventData.length == 0)
return true;
if (typeof(eventData) === 'string' || eventData instanceof String) {
return eventData.length == 0;
}
return false;
};
TimelineModelEmptyImporter.prototype = {
__proto__: Object.prototype,
importEvents : function() {
} }
};
TimelineModel.registerImporter(TimelineModelEmptyImporter);
TimelineModel.prototype = { TimelineModel.prototype = {
__proto__: cr.EventTarget.prototype, __proto__: cr.EventTarget.prototype,
...@@ -787,4 +808,5 @@ cr.define('tracing', function() { ...@@ -787,4 +808,5 @@ cr.define('tracing', function() {
TimelineCpu: TimelineCpu, TimelineCpu: TimelineCpu,
TimelineModel: TimelineModel TimelineModel: TimelineModel
}; };
}); });
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<!-- <!--
Copyright (c) 2011 The Chromium Authors. All rights reserved. Copyright (c) 2012 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. found in the LICENSE file.
--> -->
...@@ -115,6 +115,11 @@ function testModelBounds_OneCpu() { ...@@ -115,6 +115,11 @@ function testModelBounds_OneCpu() {
function testModelBounds_OneCpuOneThread() { function testModelBounds_OneCpuOneThread() {
} }
function testModelCanImportEmpty() {
var m;
m = new TimelineModel([]);
m = new TimelineModel("");
}
</script> </script>
</body> </body>
</html> </html>
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -65,7 +65,7 @@ cr.define('tracing', function() { ...@@ -65,7 +65,7 @@ cr.define('tracing', function() {
} }
// Might just be an array of events // Might just be an array of events
if (eventData instanceof Array && eventData[0].ph) if (eventData instanceof Array && eventData.length && eventData[0].ph)
return true; return true;
// Might be an object with a traceEvents field in it. // Might be an object with a traceEvents field in it.
......
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<!-- <!--
Copyright (c) 2011 The Chromium Authors. All rights reserved. Copyright (c) 2012 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. found in the LICENSE file.
--> -->
...@@ -21,6 +21,11 @@ found in the LICENSE file. ...@@ -21,6 +21,11 @@ found in the LICENSE file.
<body> <body>
<script> <script>
function testCanImportEmpty() {
self.assertFalse(tracing.TraceEventImporter.canImport([]));
self.assertFalse(tracing.TraceEventImporter.canImport(""));
}
function testBasicSingleThreadNonnestedParsing() { function testBasicSingleThreadNonnestedParsing() {
var events = [ var events = [
{name: 'a', args: {}, pid: 52, ts: 520, cat: 'foo', tid: 53, ph: 'B'}, {name: 'a', args: {}, pid: 52, ts: 520, cat: 'foo', tid: 53, ph: 'B'},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment