Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Nokia Inc. All rights reserved. | 2 * Copyright (C) 2008 Nokia Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 | 143 |
| 144 this._enabled = true; | 144 this._enabled = true; |
| 145 } | 145 } |
| 146 | 146 |
| 147 /** | 147 /** |
| 148 * @param {string} origin | 148 * @param {string} origin |
| 149 */ | 149 */ |
| 150 clearForOrigin(origin) { | 150 clearForOrigin(origin) { |
| 151 if (!this._enabled) | 151 if (!this._enabled) |
| 152 return; | 152 return; |
| 153 for (var isLocal of [true, false]) { | |
| 154 var key = this._storageKey(origin, isLocal); | |
| 155 var storage = this._storages[key]; | |
| 156 console.assert(storage); | |
|
caseq
2017/03/13 20:56:50
let's drop this, NPE that would happen on next lin
eostroukhov
2017/03/13 21:33:45
Done.
| |
| 157 storage.clear(); | |
| 158 } | |
| 153 this._removeOrigin(origin); | 159 this._removeOrigin(origin); |
| 154 this._addOrigin(origin); | 160 this._addOrigin(origin); |
| 155 } | 161 } |
| 156 | 162 |
| 157 /** | 163 /** |
| 158 * @param {!Common.Event} event | 164 * @param {!Common.Event} event |
| 159 */ | 165 */ |
| 160 _securityOriginAdded(event) { | 166 _securityOriginAdded(event) { |
| 161 this._addOrigin(/** @type {string} */ (event.data)); | 167 this._addOrigin(/** @type {string} */ (event.data)); |
| 162 } | 168 } |
| 163 | 169 |
| 164 /** | 170 /** |
| 165 * @param {string} securityOrigin | 171 * @param {string} securityOrigin |
| 166 */ | 172 */ |
| 167 _addOrigin(securityOrigin) { | 173 _addOrigin(securityOrigin) { |
| 168 var localStorageKey = this._storageKey(securityOrigin, true); | 174 for (var isLocal of [true, false]) { |
| 169 console.assert(!this._storages[localStorageKey]); | 175 var key = this._storageKey(securityOrigin, isLocal); |
| 170 var localStorage = new Resources.DOMStorage(this, securityOrigin, true); | 176 console.assert(!this._storages[key]); |
| 171 this._storages[localStorageKey] = localStorage; | 177 var storage = new Resources.DOMStorage(this, securityOrigin, isLocal); |
| 172 this.dispatchEventToListeners(Resources.DOMStorageModel.Events.DOMStorageAdd ed, localStorage); | 178 this._storages[key] = storage; |
| 173 | 179 this.dispatchEventToListeners(Resources.DOMStorageModel.Events.DOMStorageA dded, storage); |
| 174 var sessionStorageKey = this._storageKey(securityOrigin, false); | 180 } |
| 175 console.assert(!this._storages[sessionStorageKey]); | |
| 176 var sessionStorage = new Resources.DOMStorage(this, securityOrigin, false); | |
| 177 this._storages[sessionStorageKey] = sessionStorage; | |
| 178 this.dispatchEventToListeners(Resources.DOMStorageModel.Events.DOMStorageAdd ed, sessionStorage); | |
| 179 } | 181 } |
| 180 | 182 |
| 181 /** | 183 /** |
| 182 * @param {!Common.Event} event | 184 * @param {!Common.Event} event |
| 183 */ | 185 */ |
| 184 _securityOriginRemoved(event) { | 186 _securityOriginRemoved(event) { |
| 185 this._removeOrigin(/** @type {string} */ (event.data)); | 187 this._removeOrigin(/** @type {string} */ (event.data)); |
| 186 } | 188 } |
| 187 | 189 |
| 188 /** | 190 /** |
| 189 * @param {string} securityOrigin | 191 * @param {string} securityOrigin |
| 190 */ | 192 */ |
| 191 _removeOrigin(securityOrigin) { | 193 _removeOrigin(securityOrigin) { |
| 192 var localStorageKey = this._storageKey(securityOrigin, true); | 194 for (var isLocal of [true, false]) { |
| 193 var localStorage = this._storages[localStorageKey]; | 195 var key = this._storageKey(securityOrigin, isLocal); |
| 194 console.assert(localStorage); | 196 var storage = this._storages[key]; |
| 195 delete this._storages[localStorageKey]; | 197 console.assert(storage); |
| 196 this.dispatchEventToListeners(Resources.DOMStorageModel.Events.DOMStorageRem oved, localStorage); | 198 delete this._storages[key]; |
| 197 | 199 this.dispatchEventToListeners(Resources.DOMStorageModel.Events.DOMStorageR emoved, storage); |
| 198 var sessionStorageKey = this._storageKey(securityOrigin, false); | 200 } |
| 199 var sessionStorage = this._storages[sessionStorageKey]; | |
| 200 console.assert(sessionStorage); | |
| 201 delete this._storages[sessionStorageKey]; | |
| 202 this.dispatchEventToListeners(Resources.DOMStorageModel.Events.DOMStorageRem oved, sessionStorage); | |
| 203 } | 201 } |
| 204 | 202 |
| 205 /** | 203 /** |
| 206 * @param {string} securityOrigin | 204 * @param {string} securityOrigin |
| 207 * @param {boolean} isLocalStorage | 205 * @param {boolean} isLocalStorage |
| 208 * @return {string} | 206 * @return {string} |
| 209 */ | 207 */ |
| 210 _storageKey(securityOrigin, isLocalStorage) { | 208 _storageKey(securityOrigin, isLocalStorage) { |
| 211 return JSON.stringify(Resources.DOMStorage.storageId(securityOrigin, isLocal Storage)); | 209 return JSON.stringify(Resources.DOMStorage.storageId(securityOrigin, isLocal Storage)); |
| 212 } | 210 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 * @param {string} key | 335 * @param {string} key |
| 338 * @param {string} oldValue | 336 * @param {string} oldValue |
| 339 * @param {string} value | 337 * @param {string} value |
| 340 */ | 338 */ |
| 341 domStorageItemUpdated(storageId, key, oldValue, value) { | 339 domStorageItemUpdated(storageId, key, oldValue, value) { |
| 342 this._model._domStorageItemUpdated(storageId, key, oldValue, value); | 340 this._model._domStorageItemUpdated(storageId, key, oldValue, value); |
| 343 } | 341 } |
| 344 }; | 342 }; |
| 345 | 343 |
| 346 Resources.DOMStorageModel._symbol = Symbol('DomStorage'); | 344 Resources.DOMStorageModel._symbol = Symbol('DomStorage'); |
| OLD | NEW |