| OLD | NEW |
| 1 // Copyright 2014 The Chromium OS Authors. All rights reserved. | 1 // Copyright 2014 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 * Defines the protocol used to communicate between JS and NaCL. | 8 * Defines the protocol used to communicate between JS and NaCL. |
| 9 * This should be consistent with cpp/request.h. | 9 * This should be consistent with cpp/request.h. |
| 10 * @namespace | 10 * @namespace |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 METADATA: 'metadata', // Should be a dictionary. | 25 METADATA: 'metadata', // Should be a dictionary. |
| 26 ARCHIVE_SIZE: 'archive_size', // Should be a string as only int is | 26 ARCHIVE_SIZE: 'archive_size', // Should be a string as only int is |
| 27 // supported by pp::Var on C++. | 27 // supported by pp::Var on C++. |
| 28 INDEX: 'index', // Should be a string. Same reason as ARCHIVE_SIZE. | 28 INDEX: 'index', // Should be a string. Same reason as ARCHIVE_SIZE. |
| 29 ENCODING: 'encoding', // Should be a string. | 29 ENCODING: 'encoding', // Should be a string. |
| 30 OPEN_REQUEST_ID: 'open_request_id', // Should be a string, just like | 30 OPEN_REQUEST_ID: 'open_request_id', // Should be a string, just like |
| 31 // REQUEST_ID. | 31 // REQUEST_ID. |
| 32 READ_FILE_DATA: 'read_file_data', // Should be an ArrayBuffer. | 32 READ_FILE_DATA: 'read_file_data', // Should be an ArrayBuffer. |
| 33 HAS_MORE_DATA: 'has_more_data', // Should be a boolean. | 33 HAS_MORE_DATA: 'has_more_data', // Should be a boolean. |
| 34 PASSPHRASE: 'passphrase', // Should be a string. | 34 PASSPHRASE: 'passphrase', // Should be a string. |
| 35 SRC_FILE: 'src_file', // Should be a string. |
| 36 SRC_LINE: 'src_line', // Should be a int. |
| 37 SRC_FUNC: 'src_func', // Should be a string. |
| 38 MESSAGE: 'message', // Should be a string. |
| 35 | 39 |
| 36 // Mandatory keys for all packing operations. | 40 // Mandatory keys for all packing operations. |
| 37 COMPRESSOR_ID: 'compressor_id', // Should be an int. | 41 COMPRESSOR_ID: 'compressor_id', // Should be an int. |
| 38 | 42 |
| 39 // Optional keys unique to packing operations. | 43 // Optional keys unique to packing operations. |
| 40 ENTRY_ID: 'entry_id', // Should be an int. | 44 ENTRY_ID: 'entry_id', // Should be an int. |
| 41 PATHNAME: 'pathname', // should be a string. | 45 PATHNAME: 'pathname', // should be a string. |
| 42 FILE_SIZE: 'file_size', // should be a string. Same reason | 46 FILE_SIZE: 'file_size', // should be a string. Same reason |
| 43 // as ARCHIVE_SIZE. | 47 // as ARCHIVE_SIZE. |
| 44 IS_DIRECTORY: 'is_directory', // should be a boolean. | 48 IS_DIRECTORY: 'is_directory', // should be a boolean. |
| 45 MODIFICATION_TIME: 'modification_time', // should be a string. | 49 MODIFICATION_TIME: 'modification_time', // should be a string. |
| 46 // (mm/dd/yy h:m:s) | 50 // (mm/dd/yy h:m:s) |
| 47 HAS_ERROR: 'has_error', // Should be a boolean Sent from JS | 51 HAS_ERROR: 'has_error', // Should be a boolean Sent from JS |
| 48 // to NaCL. | 52 // to NaCL. |
| 49 | 53 |
| 50 // Optional keys used for both packing and unpacking operations. | 54 // Optional keys used for both packing and unpacking operations. |
| 51 ERROR: 'error', // Should be a string. | 55 ERROR: 'error', // Should be a string. |
| 52 CHUNK_BUFFER: 'chunk_buffer', // Should be an ArrayBuffer. | 56 CHUNK_BUFFER: 'chunk_buffer', // Should be an ArrayBuffer. |
| 53 OFFSET: 'offset', // Should be a string. Same reason as ARCHIVE_SIZE. | 57 OFFSET: 'offset', // Should be a string. Same reason as ARCHIVE_SIZE. |
| 54 LENGTH: 'length', // Should be a string. Same reason as ARCHIVE_SIZE. | 58 LENGTH: 'length' // Should be a string. Same reason as ARCHIVE_SIZE. |
| 55 SRC_FILE: 'src_file', // Should be a string. | |
| 56 SRC_LINE: 'src_line', // Should be a int. | |
| 57 SRC_FUNC: 'src_func', // Should be a string. | |
| 58 MESSAGE: 'message', // Should be a string. | |
| 59 }, | 59 }, |
| 60 | 60 |
| 61 /** | 61 /** |
| 62 * Defines request operations. These operation should be the same as the | 62 * Defines request operations. These operation should be the same as the |
| 63 * operations on the NaCL side. FILE_SYSTEM_ID and REQUEST_ID are mandatory | 63 * operations on the NaCL side. FILE_SYSTEM_ID and REQUEST_ID are mandatory |
| 64 * for all unpack requests, while COMPRESSOR_ID is required for all pack | 64 * for all unpack requests, while COMPRESSOR_ID is required for all pack |
| 65 * requests. All the values of unpacking operations must be smaller than any | 65 * requests. All the values of unpacking operations must be smaller than any |
| 66 * packing operation (except errors). | 66 * packing operation (except errors). |
| 67 * @enum {number} | 67 * @enum {number} |
| 68 */ | 68 */ |
| 69 Operation: { | 69 Operation: { |
| 70 READ_METADATA: 0, | |
| 71 READ_METADATA_DONE: 1, | 70 READ_METADATA_DONE: 1, |
| 72 READ_CHUNK: 2, | 71 READ_CHUNK: 2, |
| 73 READ_CHUNK_DONE: 3, | 72 READ_CHUNK_DONE: 3, |
| 74 READ_CHUNK_ERROR: 4, | 73 READ_CHUNK_ERROR: 4, |
| 75 READ_PASSPHRASE: 5, | 74 READ_PASSPHRASE: 5, |
| 76 READ_PASSPHRASE_DONE: 6, | 75 READ_PASSPHRASE_DONE: 6, |
| 77 READ_PASSPHRASE_ERROR: 7, | 76 READ_PASSPHRASE_ERROR: 7, |
| 78 CLOSE_VOLUME: 8, | 77 CLOSE_VOLUME: 8, |
| 79 OPEN_FILE: 9, | 78 OPEN_FILE: 9, |
| 80 OPEN_FILE_DONE: 10, | 79 OPEN_FILE_DONE: 10, |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 */ | 354 */ |
| 356 createCloseArchiveRequest: function(compressorId, hasError) { | 355 createCloseArchiveRequest: function(compressorId, hasError) { |
| 357 var request = {}; | 356 var request = {}; |
| 358 request[unpacker.request.Key.OPERATION] = | 357 request[unpacker.request.Key.OPERATION] = |
| 359 unpacker.request.Operation.CLOSE_ARCHIVE; | 358 unpacker.request.Operation.CLOSE_ARCHIVE; |
| 360 request[unpacker.request.Key.COMPRESSOR_ID] = compressorId; | 359 request[unpacker.request.Key.COMPRESSOR_ID] = compressorId; |
| 361 request[unpacker.request.Key.HAS_ERROR] = hasError; | 360 request[unpacker.request.Key.HAS_ERROR] = hasError; |
| 362 return request; | 361 return request; |
| 363 } | 362 } |
| 364 }; | 363 }; |
| OLD | NEW |