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
5 found in the LICENSE file.
8 <link rel="import" href="/tracing/importer/jszip.html">
9 <link rel="import" href="/tracing/importer/importer.html">
10 <link rel="import" href="/tracing/importer/gzip_importer.html">
11 <link rel="import" href="/tracing/trace_model.html">
17 * @fileoverview ZipImporter inflates zip compressed data and passes it along
18 * to an actual importer.
20 tvcm.exportTo('tracing.importer', function() {
21 var Importer = tracing.importer.Importer;
23 function ZipImporter(model, eventData) {
24 if (eventData instanceof ArrayBuffer)
25 eventData = new Uint8Array(eventData);
27 this.eventData_ = eventData;
31 * @param {eventData} string Possibly zip compressed data.
32 * @return {boolean} Whether eventData looks like zip compressed data.
34 ZipImporter.canImport = function(eventData) {
36 if (eventData instanceof ArrayBuffer)
37 header = new Uint8Array(eventData.slice(0, 2));
38 else if (typeof(eventData) === 'string' || eventData instanceof String)
39 header = [eventData.charCodeAt(0), eventData.charCodeAt(1)];
42 return header[0] === 'P'.charCodeAt(0) && header[1] === 'K'.charCodeAt(0);
45 ZipImporter.prototype = {
46 __proto__: Importer.prototype,
48 extractSubtraces: function() {
49 var zip = new JSZip(this.eventData_);
51 for (var idx in zip.files)
52 subtraces.push(zip.files[idx].asText());
57 tracing.TraceModel.registerImporter(ZipImporter);
60 ZipImporter: ZipImporter