| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 169 |
| 170 _loadChunk() { | 170 _loadChunk() { |
| 171 var chunkStart = this._loadedSize; | 171 var chunkStart = this._loadedSize; |
| 172 var chunkEnd = Math.min(this._fileSize, chunkStart + this._chunkSize); | 172 var chunkEnd = Math.min(this._fileSize, chunkStart + this._chunkSize); |
| 173 var nextPart = this._file.slice(chunkStart, chunkEnd); | 173 var nextPart = this._file.slice(chunkStart, chunkEnd); |
| 174 this._reader.readAsArrayBuffer(nextPart); | 174 this._reader.readAsArrayBuffer(nextPart); |
| 175 } | 175 } |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 /** | 178 /** |
| 179 * @param {function(!File)} callback | |
| 180 * @return {!Node} | |
| 181 */ | |
| 182 Bindings.createFileSelectorElement = function(callback) { | |
| 183 var fileSelectorElement = createElement('input'); | |
| 184 fileSelectorElement.type = 'file'; | |
| 185 fileSelectorElement.style.display = 'none'; | |
| 186 fileSelectorElement.setAttribute('tabindex', -1); | |
| 187 fileSelectorElement.onchange = onChange; | |
| 188 function onChange(event) { | |
| 189 callback(fileSelectorElement.files[0]); | |
| 190 } | |
| 191 return fileSelectorElement; | |
| 192 }; | |
| 193 | |
| 194 /** | |
| 195 * @implements {Common.OutputStream} | 179 * @implements {Common.OutputStream} |
| 196 * @unrestricted | 180 * @unrestricted |
| 197 */ | 181 */ |
| 198 Bindings.FileOutputStream = class { | 182 Bindings.FileOutputStream = class { |
| 199 /** | 183 /** |
| 200 * @param {string} fileName | 184 * @param {string} fileName |
| 201 * @param {function(boolean)} callback | 185 * @param {function(boolean)} callback |
| 202 */ | 186 */ |
| 203 open(fileName, callback) { | 187 open(fileName, callback) { |
| 204 this._closed = false; | 188 this._closed = false; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 if (callback) | 232 if (callback) |
| 249 callback(this); | 233 callback(this); |
| 250 if (!this._writeCallbacks.length) { | 234 if (!this._writeCallbacks.length) { |
| 251 if (this._closed) { | 235 if (this._closed) { |
| 252 Workspace.fileManager.removeEventListener(Workspace.FileManager.Events.A
ppendedToURL, this._onAppendDone, this); | 236 Workspace.fileManager.removeEventListener(Workspace.FileManager.Events.A
ppendedToURL, this._onAppendDone, this); |
| 253 Workspace.fileManager.close(this._fileName); | 237 Workspace.fileManager.close(this._fileName); |
| 254 } | 238 } |
| 255 } | 239 } |
| 256 } | 240 } |
| 257 }; | 241 }; |
| OLD | NEW |