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

Side by Side Diff: ui/file_manager/file_manager/common/js/util.js

Issue 2578863003: Files app: Handle chrome.runtime.lastError for chrome.storage API calls. (Closed)
Patch Set: Append chrome.runtime.lastError.message for error messages. Created 4 years 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
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/app_state_controller.js » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 * Namespace for utility functions. 6 * Namespace for utility functions.
7 */ 7 */
8 var util = {}; 8 var util = {};
9 9
10 /** 10 /**
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 380
381 /** 381 /**
382 * Save app launch data to the local storage. 382 * Save app launch data to the local storage.
383 */ 383 */
384 util.saveAppState = function() { 384 util.saveAppState = function() {
385 if (!window.appState) 385 if (!window.appState)
386 return; 386 return;
387 var items = {}; 387 var items = {};
388 388
389 items[window.appID] = JSON.stringify(window.appState); 389 items[window.appID] = JSON.stringify(window.appState);
390 chrome.storage.local.set(items); 390 chrome.storage.local.set(items, function() {
391 if (chrome.runtime.lastError)
392 console.error('Failed to save app state: ' +
393 chrome.runtime.lastError.message);
394 });
391 }; 395 };
392 396
393 /** 397 /**
394 * AppCache is a persistent timestamped key-value storage backed by 398 * AppCache is a persistent timestamped key-value storage backed by
395 * HTML5 local storage. 399 * HTML5 local storage.
396 * 400 *
397 * It is not designed for frequent access. In order to avoid costly 401 * It is not designed for frequent access. In order to avoid costly
398 * localStorage iteration all data is kept in a single localStorage item. 402 * localStorage iteration all data is kept in a single localStorage item.
399 * There is no in-memory caching, so concurrent access is _almost_ safe. 403 * There is no in-memory caching, so concurrent access is _almost_ safe.
400 * 404 *
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 * @return {!Promise} A promise which can be rejected by timeout. 1065 * @return {!Promise} A promise which can be rejected by timeout.
1062 */ 1066 */
1063 util.timeoutPromise = function(promise, ms, opt_message) { 1067 util.timeoutPromise = function(promise, ms, opt_message) {
1064 return Promise.race([ 1068 return Promise.race([
1065 promise, 1069 promise,
1066 util.delay(ms).then(function() { 1070 util.delay(ms).then(function() {
1067 throw new Error(opt_message || 'Operation timed out.'); 1071 throw new Error(opt_message || 'Operation timed out.');
1068 }) 1072 })
1069 ]); 1073 ]);
1070 }; 1074 };
OLDNEW
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/app_state_controller.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698