Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 var WallpaperUtil = {}; | 5 var WallpaperUtil = {}; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Saves value to local storage that associates with key. | 8 * Saves value to local storage that associates with key. |
| 9 * @param {string} key The key that associates with value. | 9 * @param {string} key The key that associates with value. |
| 10 * @param {string} value The value to save to local storage. | 10 * @param {string} value The value to save to local storage. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 var xhr; | 54 var xhr; |
| 55 if (opt_xhr) | 55 if (opt_xhr) |
| 56 xhr = opt_xhr; | 56 xhr = opt_xhr; |
| 57 else | 57 else |
| 58 xhr = new XMLHttpRequest(); | 58 xhr = new XMLHttpRequest(); |
| 59 | 59 |
| 60 try { | 60 try { |
| 61 xhr.addEventListener('loadend', function(e) { | 61 xhr.addEventListener('loadend', function(e) { |
| 62 if (this.status == 200) { | 62 if (this.status == 200) { |
| 63 onSuccess(this); | 63 onSuccess(this); |
| 64 } else if (this.status == 0) { | |
|
flackr
2013/09/06 15:44:00
A status of 0 can also result from a network error
| |
| 65 // The status attribute may return 0 if this request is aborted when | |
| 66 // readystate is UNSENT or OPENED. No error message should show. See | |
| 67 // http://crbug.com/242581. | |
| 68 return; | |
| 64 } else { | 69 } else { |
| 65 onFailure(); | 70 onFailure(); |
| 66 } | 71 } |
| 67 }); | 72 }); |
| 68 xhr.open('GET', url, true); | 73 xhr.open('GET', url, true); |
| 69 xhr.responseType = type; | 74 xhr.responseType = type; |
| 70 xhr.send(null); | 75 xhr.send(null); |
| 71 } catch (e) { | 76 } catch (e) { |
| 72 onFailure(); | 77 onFailure(); |
| 73 } | 78 } |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 94 chrome.wallpaperPrivate.setWallpaper(xhr.response, layout, url, | 99 chrome.wallpaperPrivate.setWallpaper(xhr.response, layout, url, |
| 95 onSuccess); | 100 onSuccess); |
| 96 self.saveWallpaperInfo(url, layout, | 101 self.saveWallpaperInfo(url, layout, |
| 97 Constants.WallpaperSourceEnum.Online); | 102 Constants.WallpaperSourceEnum.Online); |
| 98 } else { | 103 } else { |
| 99 onFailure(); | 104 onFailure(); |
| 100 } | 105 } |
| 101 }, onFailure); | 106 }, onFailure); |
| 102 }); | 107 }); |
| 103 }; | 108 }; |
| OLD | NEW |