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

Side by Side Diff: tracing/tracing/extras/importer/gzip_importer.html

Issue 1739663003: Use TextDecoder instead of JSZip.utils.transformTo in GzipImporter (Closed) Base URL: git@github.com:catapult-project/catapult.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | 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 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright (c) 2013 The Chromium Authors. All rights reserved. 3 Copyright (c) 2013 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/extras/importer/jszip.html"> 8 <link rel="import" href="/tracing/extras/importer/jszip.html">
9 <link rel="import" href="/tracing/importer/importer.html"> 9 <link rel="import" href="/tracing/importer/importer.html">
10 <link rel="import" href="/tracing/model/model.html"> 10 <link rel="import" href="/tracing/model/model.html">
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 if (have_file_name) 106 if (have_file_name)
107 skipZeroTerminatedString(); 107 skipZeroTerminatedString();
108 if (have_comment) 108 if (have_comment)
109 skipZeroTerminatedString(); 109 skipZeroTerminatedString();
110 if (have_header_crc) 110 if (have_header_crc)
111 getWord(); 111 getWord();
112 112
113 // Inflate the data using jszip. 113 // Inflate the data using jszip.
114 var inflated_data = 114 var inflated_data =
115 JSZip.compressions['DEFLATE'].uncompress(data.subarray(position)); 115 JSZip.compressions['DEFLATE'].uncompress(data.subarray(position));
116 return JSZip.utils.transformTo('string', inflated_data); 116 return GzipImporter.transformToString_(inflated_data);
117 }, 117 };
118
119 /**
120 * Transforms an array-like object to a string.
121 *
122 * Note that the following two expressions yield identical results:
123 *
124 * GzipImporter.transformToString_(data)
125 * JSZip.utils.transformTo('string', data)
126 *
127 * We use a custom static method because it is faster and, more importantly,
128 * avoids OOMing on large traces. See
129 * https://github.com/catapult-project/catapult/issues/2051.
130 */
131 GzipImporter.transformToString_ = function(data) {
132 var type = JSZip.utils.getTypeOf(data);
Sami 2016/02/25 14:44:54 Is it worth having a fallback to JSZip if TextDeco
petrcermak 2016/02/25 15:22:41 Done.
133 if (type === 'string')
134 return data; // We already have a string.
135
136 if (type === 'array') {
137 // TextDecoder requires an ArrayBuffer or an ArrayBufferView.
138 data = new Uint8Array(data);
139 }
140
141 var decoder = new TextDecoder('utf-8');
142 return decoder.decode(data);
143 };
118 144
119 GzipImporter.prototype = { 145 GzipImporter.prototype = {
120 __proto__: tr.importer.Importer.prototype, 146 __proto__: tr.importer.Importer.prototype,
121 147
122 get importerName() { 148 get importerName() {
123 return 'GzipImporter'; 149 return 'GzipImporter';
124 }, 150 },
125 151
126 /** 152 /**
127 * Called by the Model to check whether the importer just encapsulates 153 * Called by the Model to check whether the importer just encapsulates
(...skipping 13 matching lines...) Expand all
141 } 167 }
142 }; 168 };
143 169
144 tr.importer.Importer.register(GzipImporter); 170 tr.importer.Importer.register(GzipImporter);
145 171
146 return { 172 return {
147 GzipImporter: GzipImporter 173 GzipImporter: GzipImporter
148 }; 174 };
149 }); 175 });
150 </script> 176 </script>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698