| 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 }.bind(this); | 266 }.bind(this); |
| 267 | 267 |
| 268 // Refreshes the access token and retries the request. | 268 // Refreshes the access token and retries the request. |
| 269 var maybeRetryCall = function(code) { | 269 var maybeRetryCall = function(code) { |
| 270 if (this.aborted_) | 270 if (this.aborted_) |
| 271 return; | 271 return; |
| 272 requestTokenAndCall(true, onMaybeSuccess, onMaybeFailure); | 272 requestTokenAndCall(true, onMaybeSuccess, onMaybeFailure); |
| 273 }.bind(this); | 273 }.bind(this); |
| 274 | 274 |
| 275 // Do not request a token for local resources, since it is not necessary. | 275 // Do not request a token for local resources, since it is not necessary. |
| 276 if (url.indexOf('filesystem:') === 0) { | 276 if (/^filesystem:/.test(url)) { |
| 277 this.xhr_ = AuthorizedXHR.load_(null, url, onMaybeSuccess, onMaybeFailure); | 277 // Add the query parameter to avoid browser cache. crbug.com/378648 |
| 278 var noCacheUrl = url + '?nocache=' + Date.now(); |
| 279 this.xhr_ = AuthorizedXHR.load_( |
| 280 null, |
| 281 noCacheUrl, |
| 282 onMaybeSuccess, |
| 283 onMaybeFailure); |
| 278 return; | 284 return; |
| 279 } | 285 } |
| 280 | 286 |
| 281 // Make the request with reusing the current token. If it fails, then retry. | 287 // Make the request with reusing the current token. If it fails, then retry. |
| 282 requestTokenAndCall(false, onMaybeSuccess, maybeRetryCall); | 288 requestTokenAndCall(false, onMaybeSuccess, maybeRetryCall); |
| 283 }; | 289 }; |
| 284 | 290 |
| 285 /** | 291 /** |
| 286 * Fetches data using authorized XmlHttpRequest with the provided OAuth2 token. | 292 * Fetches data using authorized XmlHttpRequest with the provided OAuth2 token. |
| 287 * If the token is invalid, the request will fail. | 293 * If the token is invalid, the request will fail. |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 this.image_.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAA' + | 435 this.image_.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAA' + |
| 430 'ABAAEAAAICTAEAOw=='; | 436 'ABAAEAAAICTAEAOw=='; |
| 431 | 437 |
| 432 this.xhr_.onload = function() {}; | 438 this.xhr_.onload = function() {}; |
| 433 this.xhr_.abort(); | 439 this.xhr_.abort(); |
| 434 | 440 |
| 435 // Dispose memory allocated by Canvas. | 441 // Dispose memory allocated by Canvas. |
| 436 this.canvas_.width = 0; | 442 this.canvas_.width = 0; |
| 437 this.canvas_.height = 0; | 443 this.canvas_.height = 0; |
| 438 }; | 444 }; |
| OLD | NEW |