| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium 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 * Creates and starts downloading and then resizing of the image. Finally, | 8 * Creates and starts downloading and then resizing of the image. Finally, |
| 9 * returns the image using the callback. | 9 * returns the image using the callback. |
| 10 * | 10 * |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 this.sendImageData_(imageData); | 364 this.sendImageData_(imageData); |
| 365 this.saveToCache_(imageData); | 365 this.saveToCache_(imageData); |
| 366 }; | 366 }; |
| 367 | 367 |
| 368 /** | 368 /** |
| 369 * Sends the resized image via the callback. | 369 * Sends the resized image via the callback. |
| 370 * @param {string} data Compressed image data. | 370 * @param {string} data Compressed image data. |
| 371 * @private | 371 * @private |
| 372 */ | 372 */ |
| 373 Request.prototype.sendImageData_ = function(data) { | 373 Request.prototype.sendImageData_ = function(data) { |
| 374 this.sendResponse_({status: 'success', | 374 this.sendResponse_( |
| 375 data: data, | 375 {status: 'success', data: data, taskId: this.request_.taskId}); |
| 376 taskId: this.request_.taskId}); | |
| 377 }; | 376 }; |
| 378 | 377 |
| 379 /** | 378 /** |
| 380 * Handler, when contents are loaded into the image element. Performs resizing | 379 * Handler, when contents are loaded into the image element. Performs resizing |
| 381 * and finalizes the request process. | 380 * and finalizes the request process. |
| 382 * | 381 * |
| 383 * @param {function()} callback Completion callback. | 382 * @param {function()} callback Completion callback. |
| 384 * @private | 383 * @private |
| 385 */ | 384 */ |
| 386 Request.prototype.onImageLoad_ = function(callback) { | 385 Request.prototype.onImageLoad_ = function(callback) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 400 }; | 399 }; |
| 401 | 400 |
| 402 /** | 401 /** |
| 403 * Handler, when loading of the image fails. Sends a failure response and | 402 * Handler, when loading of the image fails. Sends a failure response and |
| 404 * finalizes the request process. | 403 * finalizes the request process. |
| 405 * | 404 * |
| 406 * @param {function()} callback Completion callback. | 405 * @param {function()} callback Completion callback. |
| 407 * @private | 406 * @private |
| 408 */ | 407 */ |
| 409 Request.prototype.onImageError_ = function(callback) { | 408 Request.prototype.onImageError_ = function(callback) { |
| 410 this.sendResponse_({status: 'error', | 409 this.sendResponse_( |
| 411 taskId: this.request_.taskId}); | 410 {status: 'error', taskId: this.request_.taskId}); |
| 412 this.cleanup_(); | 411 this.cleanup_(); |
| 413 this.downloadCallback_(); | 412 this.downloadCallback_(); |
| 414 }; | 413 }; |
| 415 | 414 |
| 416 /** | 415 /** |
| 417 * Cancels the request. | 416 * Cancels the request. |
| 418 */ | 417 */ |
| 419 Request.prototype.cancel = function() { | 418 Request.prototype.cancel = function() { |
| 420 this.cleanup_(); | 419 this.cleanup_(); |
| 421 | 420 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 436 this.image_.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAA' + | 435 this.image_.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAA' + |
| 437 'ABAAEAAAICTAEAOw=='; | 436 'ABAAEAAAICTAEAOw=='; |
| 438 | 437 |
| 439 this.xhr_.onload = function() {}; | 438 this.xhr_.onload = function() {}; |
| 440 this.xhr_.abort(); | 439 this.xhr_.abort(); |
| 441 | 440 |
| 442 // Dispose memory allocated by Canvas. | 441 // Dispose memory allocated by Canvas. |
| 443 this.canvas_.width = 0; | 442 this.canvas_.width = 0; |
| 444 this.canvas_.height = 0; | 443 this.canvas_.height = 0; |
| 445 }; | 444 }; |
| OLD | NEW |