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

Unified Diff: ui/file_manager/audio_player/js/audio_player_model.js

Issue 1495873002: AudioPlayer: Stop using Object.observe() and Array.observe(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Listen to property-change events for four states explicitly. Stop using Array.observe. Created 5 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 side-by-side diff with in-line comments
Download patch
Index: ui/file_manager/audio_player/js/audio_player_model.js
diff --git a/ui/file_manager/audio_player/js/audio_player_model.js b/ui/file_manager/audio_player/js/audio_player_model.js
deleted file mode 100644
index 7bbef274cd33a9cd79d71012a4adf2ddc7754b06..0000000000000000000000000000000000000000
--- a/ui/file_manager/audio_player/js/audio_player_model.js
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/**
- * The model class for audio player.
- * @constructor
- */
-function AudioPlayerModel() {}
-
-AudioPlayerModel.prototype.initialize = function(callback) {
- 'use strict';
-
- /**
- * List of values to be stored into the model.
- * @type {!Object<*>}
- * @const
- */
- var VALUES =
- /**
- * They will be used as properties of AudioPlayerModel.
- * @lends {AudioPlayerModel.prototype}
- */
- {
- shuffle: false,
- repeat: false,
- volume: 100,
- expanded: false,
- };
-
- /**
- * Prefix of the stored values in the storage.
- * @type {string}
- */
- var STORAGE_PREFIX = 'audioplayer-';
-
- /**
- * Save the values in the model into the storage.
- * @param {AudioPlayerModel} model The model.
- */
- function saveModel(model) {
- var objectToBeSaved = {};
- for (var key in VALUES) {
- objectToBeSaved[STORAGE_PREFIX + key] = model[key];
- }
-
- chrome.storage.local.set(objectToBeSaved);
- };
-
- /**
- * Load the values in the model from the storage.
- * @param {AudioPlayerModel} model The model.
- * @param {function()} inCallback Called when the load is completed.
- */
- function loadModel(model, inCallback) {
- // Restores the values from the storage
- var objectsToBeRead = Object.keys(VALUES).
- map(function(a) {
- return STORAGE_PREFIX + a;
- });
-
- chrome.storage.local.get(objectsToBeRead, function(result) {
- for (var key in result) {
- // Strips the prefix.
- model[key.substr(STORAGE_PREFIX.length)] = result[key];
- }
- inCallback();
- });
- };
-
- // Initializes values.
- for (var key in VALUES) {
- this[key] = VALUES[key];
- }
- Object.seal(this);
-
- // Restores the values from the storage
- var target = this;
- loadModel(target, function() {
- // Installs observer to watch changes of the values.
- Object.observe(target, function(changes) {
- saveModel(target);
- });
- callback();
- });
-}
« no previous file with comments | « ui/file_manager/audio_player/js/audio_player.js ('k') | ui/file_manager/audio_player/js/audio_player_scripts.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698