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

Side by Side Diff: ui/file_manager/zip_archiver/js/compressor.js

Issue 2815063002: Rename variable, class, function, etc from libarchive to minizip. (Closed)
Patch Set: Created 3 years, 8 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 | « ui/file_manager/zip_archiver/js/app.js ('k') | ui/file_manager/zip_archiver/js/decompressor.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium OS Authors. All rights reserved. 1 // Copyright 2017 The Chromium OS 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * A class that takes care of communication with NaCL and creates an archive. 8 * A class that takes care of communication with NaCL and creates an archive.
9 * One instance of this class is created for each pack request. Since multiple 9 * One instance of this class is created for each pack request. Since multiple
10 * compression requests can be in progress at the same time, each instance has 10 * compression requests can be in progress at the same time, each instance has
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // When the name does not have extension. 131 // When the name does not have extension.
132 // TODO(takise): This converts file.tar.gz to file.tar.zip. 132 // TODO(takise): This converts file.tar.gz to file.tar.zip.
133 if (idx === -1) 133 if (idx === -1)
134 return name + '.zip'; 134 return name + '.zip';
135 // When the name has extension. 135 // When the name has extension.
136 return name.substring(0, idx) + '.zip'; 136 return name.substring(0, idx) + '.zip';
137 }; 137 };
138 138
139 /** 139 /**
140 * Starts actual compressing process. 140 * Starts actual compressing process.
141 * Creates an archive file and requests libarchive to create an archive object. 141 * Creates an archive file and requests minizip to create an archive object.
142 * @param {function(!unpacker.types.CompressorId)} onSuccess 142 * @param {function(!unpacker.types.CompressorId)} onSuccess
143 * @param {function(!unpacker.types.CompressorId)} onError 143 * @param {function(!unpacker.types.CompressorId)} onError
144 */ 144 */
145 unpacker.Compressor.prototype.compress = function(onSuccess, onError) { 145 unpacker.Compressor.prototype.compress = function(onSuccess, onError) {
146 this.onSuccess_ = onSuccess; 146 this.onSuccess_ = onSuccess;
147 this.onError_ = onError; 147 this.onError_ = onError;
148 148
149 this.getArchiveFile_(); 149 this.getArchiveFile_();
150 }; 150 };
151 151
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 getEntries(); 258 getEntries();
259 259
260 // Get the metadata of this dir itself. 260 // Get the metadata of this dir itself.
261 this.getSingleMetadata_(dir); 261 this.getSingleMetadata_(dir);
262 } 262 }
263 263
264 /** 264 /**
265 * Pops an entry from the queue and adds it to the archive. 265 * Pops an entry from the queue and adds it to the archive.
266 * If another entry is in progress, this function does nothing. If there is no 266 * If another entry is in progress, this function does nothing. If there is no
267 * entry in the queue, it shifts to close archive process. Otherwise, this sends 267 * entry in the queue, it shifts to close archive process. Otherwise, this sends
268 * an add to archive request for a popped entry with its metadata to libarchive. 268 * an add to archive request for a popped entry with its metadata to minizip.
269 * @private 269 * @private
270 */ 270 */
271 unpacker.Compressor.prototype.sendAddToArchiveRequest_ = function() { 271 unpacker.Compressor.prototype.sendAddToArchiveRequest_ = function() {
272 // Another process is in progress. 272 // Another process is in progress.
273 if (this.entryIdInProgress_ != 0) 273 if (this.entryIdInProgress_ != 0)
274 return; 274 return;
275 275
276 // All entries have already been archived. 276 // All entries have already been archived.
277 if (this.pendingAddToArchiveRequests_.length === 0) { 277 if (this.pendingAddToArchiveRequests_.length === 0) {
278 if (this.metadataRequestsInProgress_.size === 0) 278 if (this.metadataRequestsInProgress_.size === 0)
(...skipping 15 matching lines...) Expand all
294 var modificationTime = utc.getTime() - (utc.getTimezoneOffset() * 60000); 294 var modificationTime = utc.getTime() - (utc.getTimezoneOffset() * 60000);
295 295
296 var request = unpacker.request.createAddToArchiveRequest( 296 var request = unpacker.request.createAddToArchiveRequest(
297 this.compressorId_, entryId, fullPath, 297 this.compressorId_, entryId, fullPath,
298 this.metadata_[entryId].size, modificationTime, 298 this.metadata_[entryId].size, modificationTime,
299 this.entries_[entryId].isDirectory); 299 this.entries_[entryId].isDirectory);
300 this.naclModule_.postMessage(request); 300 this.naclModule_.postMessage(request);
301 } 301 }
302 302
303 /** 303 /**
304 * Sends a close archive request to libarchive. libarchive writes metadata of 304 * Sends a close archive request to minizip. minizip writes metadata of
305 * the archive itself on the archive and releases objects obtainted in the 305 * the archive itself on the archive and releases objects obtainted in the
306 * packing process. 306 * packing process.
307 */ 307 */
308 unpacker.Compressor.prototype.sendCloseArchiveRequest = function(hasError) { 308 unpacker.Compressor.prototype.sendCloseArchiveRequest = function(hasError) {
309 var request = unpacker.request.createCloseArchiveRequest( 309 var request = unpacker.request.createCloseArchiveRequest(
310 this.compressorId_, hasError); 310 this.compressorId_, hasError);
311 this.naclModule_.postMessage(request); 311 this.naclModule_.postMessage(request);
312 } 312 }
313 313
314 /** 314 /**
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 ': ' + data[unpacker.request.Key.ERROR]); // The error contains 507 ': ' + data[unpacker.request.Key.ERROR]); // The error contains
508 // the '.' at the end. 508 // the '.' at the end.
509 this.onError_(this.compressorId_); 509 this.onError_(this.compressorId_);
510 break; 510 break;
511 511
512 default: 512 default:
513 console.error('Invalid NaCl operation: ' + operation + '.'); 513 console.error('Invalid NaCl operation: ' + operation + '.');
514 this.onError_(this.compressorId_); 514 this.onError_(this.compressorId_);
515 } 515 }
516 }; 516 };
OLDNEW
« no previous file with comments | « ui/file_manager/zip_archiver/js/app.js ('k') | ui/file_manager/zip_archiver/js/decompressor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698