* @param {function(!Store)} mutator * @return {!Promise} * @private
(mutator)
| 138 | * @private |
| 139 | */ |
| 140 | saveStore_(mutator) { |
| 141 | return this.getStore_() |
| 142 | .then((store) => { |
| 143 | mutator(store); |
| 144 | // Need to encode stored object to avoid plain text, |
| 145 | // but doesn't need to be base64encode. Can convert to some other |
| 146 | // encoding method for further improvement. |
| 147 | const blob = btoa(JSON.stringify(store.obj)); |
| 148 | return this.binding_.saveBlob(this.origin_, blob); |
| 149 | }) |
| 150 | .then(this.broadcastReset_.bind(this)); |
| 151 | } |
| 152 | |
| 153 | /** @private */ |
| 154 | listenToBroadcasts_() { |