Chromium Code Reviews| 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 /** | 5 /** |
| 6 * Loads and resizes an image. | 6 * Loads and resizes an image. |
| 7 * @constructor | 7 * @constructor |
| 8 */ | 8 */ |
| 9 function ImageLoader() { | 9 function ImageLoader() { |
| 10 /** | 10 /** |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 // Sending a response may fail if the receiver already went offline. | 61 // Sending a response may fail if the receiver already went offline. |
| 62 // This is not an error, but a normal and quite common situation. | 62 // This is not an error, but a normal and quite common situation. |
| 63 var failSafeSendResponse = function(response) { | 63 var failSafeSendResponse = function(response) { |
| 64 try { | 64 try { |
| 65 sendResponse(response); | 65 sendResponse(response); |
| 66 } | 66 } |
| 67 catch (e) { | 67 catch (e) { |
| 68 // Ignore the error. | 68 // Ignore the error. |
| 69 } | 69 } |
| 70 }; | 70 }; |
| 71 if (typeof request.orientation === 'number') { | 71 if (request.image_transform) { |
|
mtomasz
2017/02/16 08:53:41
Instead of overriding, can we simply pass the "ori
yamaguchi
2017/02/16 14:01:18
Done.
| |
| 72 // 'image_transform' option overrides 'orientation' option. | |
| 73 request.orientation = | |
| 74 ImageOrientation.fromRotationAndScale(request.image_transform); | |
| 75 } else if (typeof request.orientation === 'number') { | |
| 72 request.orientation = | 76 request.orientation = |
| 73 ImageOrientation.fromDriveOrientation(request.orientation); | 77 ImageOrientation.fromDriveOrientation(request.orientation); |
| 74 } else { | 78 } else { |
| 75 request.orientation = new ImageOrientation(1, 0, 0, 1); | 79 request.orientation = new ImageOrientation(1, 0, 0, 1); |
| 76 } | 80 } |
| 77 return this.onMessage_(sender.id, | 81 return this.onMessage_(sender.id, |
| 78 /** @type {LoadImageRequest} */ (request), | 82 /** @type {LoadImageRequest} */ (request), |
| 79 failSafeSendResponse); | 83 failSafeSendResponse); |
| 80 } | 84 } |
| 81 }.bind(this)); | 85 }.bind(this)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 }; | 124 }; |
| 121 | 125 |
| 122 /** | 126 /** |
| 123 * Returns the singleton instance. | 127 * Returns the singleton instance. |
| 124 * @return {ImageLoader} ImageLoader object. | 128 * @return {ImageLoader} ImageLoader object. |
| 125 */ | 129 */ |
| 126 ImageLoader.getInstance = function() { | 130 ImageLoader.getInstance = function() { |
| 127 if (!ImageLoader.instance_) | 131 if (!ImageLoader.instance_) |
| 128 ImageLoader.instance_ = new ImageLoader(); | 132 ImageLoader.instance_ = new ImageLoader(); |
| 129 return ImageLoader.instance_; | 133 return ImageLoader.instance_; |
| 130 }; | 134 }; |
| OLD | NEW |