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

Side by Side Diff: Source/devtools/front_end/timeline/TracingTimelineModel.js

Issue 454893003: Show error message on attempt to load old Timeline data into tracing based Timeline (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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
« no previous file with comments | « Source/devtools/front_end/timeline/TracingModel.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 * @constructor 6 * @constructor
7 * @param {!WebInspector.TracingModel} tracingModel 7 * @param {!WebInspector.TracingModel} tracingModel
8 * @param {!WebInspector.TimelineModel.Filter} recordFilter 8 * @param {!WebInspector.TimelineModel.Filter} recordFilter
9 * @extends {WebInspector.TimelineModel} 9 * @extends {WebInspector.TimelineModel}
10 */ 10 */
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 lastIndex = WebInspector.TextUtils.findBalancedCurlyBrackets(data, i ndex); 816 lastIndex = WebInspector.TextUtils.findBalancedCurlyBrackets(data, i ndex);
817 } while (lastIndex !== -1) 817 } while (lastIndex !== -1)
818 818
819 var json = data.slice(0, index) + "]"; 819 var json = data.slice(0, index) + "]";
820 this._buffer = data.slice(index); 820 this._buffer = data.slice(index);
821 821
822 if (!index) 822 if (!index)
823 return; 823 return;
824 824
825 if (this._firstChunk) { 825 if (this._firstChunk) {
826 this._firstChunk = false;
827 this._model.reset(); 826 this._model.reset();
828 } else { 827 } else {
829 var commaIndex = json.indexOf(","); 828 var commaIndex = json.indexOf(",");
830 if (commaIndex !== -1) 829 if (commaIndex !== -1)
831 json = json.slice(commaIndex + 1); 830 json = json.slice(commaIndex + 1);
832 json = "[" + json; 831 json = "[" + json;
833 } 832 }
834 833
835 var items; 834 var items;
836 try { 835 try {
837 items = /** @type {!Array.<!WebInspector.TracingModel.EventPayload>} */ (JSON.parse(json)); 836 items = /** @type {!Array.<!WebInspector.TracingModel.EventPayload>} */ (JSON.parse(json));
838 } catch (e) { 837 } catch (e) {
839 WebInspector.console.error("Malformed timeline data."); 838 this._reportErrorAndCancelLoading("Malformed timeline data: " + e);
840 this._model.reset();
841 this._reader.cancel();
842 this._progress.done();
843 return; 839 return;
844 } 840 }
845 841
846 this._loader.loadNextChunk(items); 842 if (this._firstChunk) {
843 this._firstChunk = false;
844 if (this._looksLikeAppVersion(items[0])) {
845 this._reportErrorAndCancelLoading("Old Timeline format is not su pported.");
846 return;
847 }
848 }
849
850 try {
851 this._loader.loadNextChunk(items);
852 } catch(e) {
853 this._reportErrorAndCancelLoading("Malformed timeline data: " + e);
854 return;
855 }
856 },
857
858 _reportErrorAndCancelLoading: function(messsage)
859 {
860 WebInspector.console.error(messsage);
861 this._model.reset();
862 this._reader.cancel();
863 this._progress.done();
864 },
865
866 _looksLikeAppVersion: function(item)
867 {
868 return typeof item === "string" && item.indexOf("Chrome") !== -1;
847 }, 869 },
848 870
849 close: function() 871 close: function()
850 { 872 {
851 this._loader.finish(); 873 this._loader.finish();
852 } 874 }
853 } 875 }
854 876
855 /** 877 /**
856 * @constructor 878 * @constructor
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 }, 919 },
898 920
899 _didWriteNextChunk: function(stream) 921 _didWriteNextChunk: function(stream)
900 { 922 {
901 if (this._recordIndex === this._payloads.length) 923 if (this._recordIndex === this._payloads.length)
902 stream.close(); 924 stream.close();
903 else 925 else
904 this._writeNextChunk(stream); 926 this._writeNextChunk(stream);
905 } 927 }
906 } 928 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/timeline/TracingModel.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698