Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: chrome/browser/resources/chromeos/wallpaper_manager/js/util.js

Issue 24040002: Fix unexpected error message when quickly select different wallpapers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 * @param {XMLHttpRequest=} opt_xhr The XMLHttpRequest object. 51 * @param {XMLHttpRequest=} opt_xhr The XMLHttpRequest object.
52 */ 52 */
53 WallpaperUtil.fetchURL = function(url, type, onSuccess, onFailure, opt_xhr) { 53 WallpaperUtil.fetchURL = function(url, type, onSuccess, onFailure, opt_xhr) {
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 // Do not use loadend here to handle both success and failure case. It gets
62 // complicated with abortion. Unexpected error message may show up. See
63 // http://crbug.com/242581.
64 xhr.addEventListener('load', function(e) {
62 if (this.status == 200) { 65 if (this.status == 200) {
63 onSuccess(this); 66 onSuccess(this);
64 } else { 67 } else {
65 onFailure(); 68 onFailure();
66 } 69 }
67 }); 70 });
71 xhr.addEventListener('error', onFailure);
68 xhr.open('GET', url, true); 72 xhr.open('GET', url, true);
69 xhr.responseType = type; 73 xhr.responseType = type;
70 xhr.send(null); 74 xhr.send(null);
71 } catch (e) { 75 } catch (e) {
72 onFailure(); 76 onFailure();
73 } 77 }
74 }; 78 };
75 79
76 /** 80 /**
77 * Sets wallpaper to online wallpaper specified by url and layout 81 * Sets wallpaper to online wallpaper specified by url and layout
(...skipping 16 matching lines...) Expand all
94 chrome.wallpaperPrivate.setWallpaper(xhr.response, layout, url, 98 chrome.wallpaperPrivate.setWallpaper(xhr.response, layout, url,
95 onSuccess); 99 onSuccess);
96 self.saveWallpaperInfo(url, layout, 100 self.saveWallpaperInfo(url, layout,
97 Constants.WallpaperSourceEnum.Online); 101 Constants.WallpaperSourceEnum.Online);
98 } else { 102 } else {
99 onFailure(); 103 onFailure();
100 } 104 }
101 }, onFailure); 105 }, onFailure);
102 }); 106 });
103 }; 107 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698