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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 setItem(key, value) { | 81 setItem(key, value) { |
| 82 this._model._agent.setDOMStorageItem(this.id, key, value); | 82 this._model._agent.setDOMStorageItem(this.id, key, value); |
| 83 } | 83 } |
| 84 | 84 |
| 85 /** | 85 /** |
| 86 * @param {string} key | 86 * @param {string} key |
| 87 */ | 87 */ |
| 88 removeItem(key) { | 88 removeItem(key) { |
| 89 this._model._agent.removeDOMStorageItem(this.id, key); | 89 this._model._agent.removeDOMStorageItem(this.id, key); |
| 90 } | 90 } |
| 91 | |
| 92 clear() { | |
|
pfeldman
2017/01/13 18:51:25
When clearing the model, it should dispatch events
eostroukhov
2017/01/19 00:42:10
Done.
| |
| 93 if (this.isLocalStorage) | |
| 94 this._model._storageAgent.clearDataForOrigin(this._securityOrigin, 'local_ storage'); | |
| 95 } | |
| 91 }; | 96 }; |
| 92 | 97 |
| 93 | 98 |
| 94 /** @enum {symbol} */ | 99 /** @enum {symbol} */ |
| 95 Resources.DOMStorage.Events = { | 100 Resources.DOMStorage.Events = { |
| 96 DOMStorageItemsCleared: Symbol('DOMStorageItemsCleared'), | 101 DOMStorageItemsCleared: Symbol('DOMStorageItemsCleared'), |
| 97 DOMStorageItemRemoved: Symbol('DOMStorageItemRemoved'), | 102 DOMStorageItemRemoved: Symbol('DOMStorageItemRemoved'), |
| 98 DOMStorageItemAdded: Symbol('DOMStorageItemAdded'), | 103 DOMStorageItemAdded: Symbol('DOMStorageItemAdded'), |
| 99 DOMStorageItemUpdated: Symbol('DOMStorageItemUpdated') | 104 DOMStorageItemUpdated: Symbol('DOMStorageItemUpdated') |
| 100 }; | 105 }; |
| 101 | 106 |
| 102 /** | 107 /** |
| 103 * @unrestricted | 108 * @unrestricted |
| 104 */ | 109 */ |
| 105 Resources.DOMStorageModel = class extends SDK.SDKModel { | 110 Resources.DOMStorageModel = class extends SDK.SDKModel { |
| 106 /** | 111 /** |
| 107 * @param {!SDK.Target} target | 112 * @param {!SDK.Target} target |
| 108 * @param {!SDK.SecurityOriginManager} securityOriginManager | 113 * @param {!SDK.SecurityOriginManager} securityOriginManager |
| 109 */ | 114 */ |
| 110 constructor(target, securityOriginManager) { | 115 constructor(target, securityOriginManager) { |
| 111 super(Resources.DOMStorageModel, target); | 116 super(Resources.DOMStorageModel, target); |
| 112 | 117 |
| 113 this._securityOriginManager = securityOriginManager; | 118 this._securityOriginManager = securityOriginManager; |
| 114 /** @type {!Object.<string, !Resources.DOMStorage>} */ | 119 /** @type {!Object.<string, !Resources.DOMStorage>} */ |
| 115 this._storages = {}; | 120 this._storages = {}; |
| 116 this._agent = target.domstorageAgent(); | 121 this._agent = target.domstorageAgent(); |
| 122 this._storageAgent = target.storageAgent(); | |
| 117 } | 123 } |
| 118 | 124 |
| 119 /** | 125 /** |
| 120 * @param {!SDK.Target} target | 126 * @param {!SDK.Target} target |
| 121 * @return {!Resources.DOMStorageModel} | 127 * @return {!Resources.DOMStorageModel} |
| 122 */ | 128 */ |
| 123 static fromTarget(target) { | 129 static fromTarget(target) { |
| 124 var model = target.model(Resources.DOMStorageModel); | 130 var model = target.model(Resources.DOMStorageModel); |
| 125 if (!model) | 131 if (!model) |
| 126 model = new Resources.DOMStorageModel(target, SDK.SecurityOriginManager.fr omTarget(target)); | 132 model = new Resources.DOMStorageModel(target, SDK.SecurityOriginManager.fr omTarget(target)); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 * @param {string} key | 342 * @param {string} key |
| 337 * @param {string} oldValue | 343 * @param {string} oldValue |
| 338 * @param {string} value | 344 * @param {string} value |
| 339 */ | 345 */ |
| 340 domStorageItemUpdated(storageId, key, oldValue, value) { | 346 domStorageItemUpdated(storageId, key, oldValue, value) { |
| 341 this._model._domStorageItemUpdated(storageId, key, oldValue, value); | 347 this._model._domStorageItemUpdated(storageId, key, oldValue, value); |
| 342 } | 348 } |
| 343 }; | 349 }; |
| 344 | 350 |
| 345 Resources.DOMStorageModel._symbol = Symbol('DomStorage'); | 351 Resources.DOMStorageModel._symbol = Symbol('DomStorage'); |
| OLD | NEW |