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

Side by Side Diff: Source/devtools/front_end/DOMStorage.js

Issue 22346003: DevTools: DOMStorage should notify the view about storage modifications instead of DOMStorageModel (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 4 months 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
OLDNEW
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 11 matching lines...) Expand all
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30 /** 30 /**
31 * @constructor 31 * @constructor
32 * @extends {WebInspector.Object}
32 * @param {string} securityOrigin 33 * @param {string} securityOrigin
33 * @param {boolean} isLocalStorage 34 * @param {boolean} isLocalStorage
34 */ 35 */
35 WebInspector.DOMStorage = function(securityOrigin, isLocalStorage) 36 WebInspector.DOMStorage = function(securityOrigin, isLocalStorage)
36 { 37 {
37 this._securityOrigin = securityOrigin; 38 this._securityOrigin = securityOrigin;
38 this._isLocalStorage = isLocalStorage; 39 this._isLocalStorage = isLocalStorage;
39 this._storageHistory = new WebInspector.DOMStorageHistory(this); 40 this._storageHistory = new WebInspector.DOMStorageHistory(this);
40 } 41 }
41 42
42 /** 43 /**
43 * @param {string} securityOrigin 44 * @param {string} securityOrigin
44 * @param {boolean} isLocalStorage 45 * @param {boolean} isLocalStorage
45 * @return {DOMStorageAgent.StorageId} 46 * @return {DOMStorageAgent.StorageId}
46 */ 47 */
47 WebInspector.DOMStorage.storageId = function(securityOrigin, isLocalStorage) 48 WebInspector.DOMStorage.storageId = function(securityOrigin, isLocalStorage)
48 { 49 {
49 return { securityOrigin: securityOrigin, isLocalStorage: isLocalStorage }; 50 return { securityOrigin: securityOrigin, isLocalStorage: isLocalStorage };
50 } 51 }
51 52
53 WebInspector.DOMStorage.Events = {
54 DOMStorageItemsCleared: "DOMStorageItemsCleared",
55 DOMStorageItemRemoved: "DOMStorageItemRemoved",
56 DOMStorageItemAdded: "DOMStorageItemAdded",
57 DOMStorageItemUpdated: "DOMStorageItemUpdated"
58 }
59
52 WebInspector.DOMStorage.prototype = { 60 WebInspector.DOMStorage.prototype = {
53 61
54 /** @return {DOMStorageAgent.StorageId} */ 62 /** @return {DOMStorageAgent.StorageId} */
55 get id() 63 get id()
56 { 64 {
57 return WebInspector.DOMStorage.storageId(this._securityOrigin, this._isL ocalStorage); 65 return WebInspector.DOMStorage.storageId(this._securityOrigin, this._isL ocalStorage);
58 }, 66 },
59 67
60 /** @return {string} */ 68 /** @return {string} */
61 get securityOrigin() 69 get securityOrigin()
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 }, 103 },
96 104
97 undo: function() 105 undo: function()
98 { 106 {
99 this._storageHistory.undo(); 107 this._storageHistory.undo();
100 }, 108 },
101 109
102 redo: function() 110 redo: function()
103 { 111 {
104 this._storageHistory.redo(); 112 this._storageHistory.redo();
105 } 113 },
114
115 __proto__: WebInspector.Object.prototype
106 } 116 }
107 117
108 /** 118 /**
109 * @constructor 119 * @constructor
110 * @param {WebInspector.DOMStorage} domStorage 120 * @param {WebInspector.DOMStorage} domStorage
111 */ 121 */
112 WebInspector.DOMStorageAction = function(domStorage) 122 WebInspector.DOMStorageAction = function(domStorage)
113 { 123 {
114 this._domStorage = domStorage; 124 this._domStorage = domStorage;
115 } 125 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 /** @type {!Object.<string, !WebInspector.DOMStorage>} */ 328 /** @type {!Object.<string, !WebInspector.DOMStorage>} */
319 this._storages = {}; 329 this._storages = {};
320 InspectorBackend.registerDOMStorageDispatcher(new WebInspector.DOMStorageDis patcher(this)); 330 InspectorBackend.registerDOMStorageDispatcher(new WebInspector.DOMStorageDis patcher(this));
321 DOMStorageAgent.enable(); 331 DOMStorageAgent.enable();
322 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeMod el.EventTypes.SecurityOriginAdded, this._securityOriginAdded, this); 332 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeMod el.EventTypes.SecurityOriginAdded, this._securityOriginAdded, this);
323 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeMod el.EventTypes.SecurityOriginRemoved, this._securityOriginRemoved, this); 333 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeMod el.EventTypes.SecurityOriginRemoved, this._securityOriginRemoved, this);
324 } 334 }
325 335
326 WebInspector.DOMStorageModel.Events = { 336 WebInspector.DOMStorageModel.Events = {
327 DOMStorageAdded: "DOMStorageAdded", 337 DOMStorageAdded: "DOMStorageAdded",
328 DOMStorageRemoved: "DOMStorageRemoved", 338 DOMStorageRemoved: "DOMStorageRemoved"
329 DOMStorageItemsCleared: "DOMStorageItemsCleared",
330 DOMStorageItemRemoved: "DOMStorageItemRemoved",
331 DOMStorageItemAdded: "DOMStorageItemAdded",
332 DOMStorageItemUpdated: "DOMStorageItemUpdated"
333 } 339 }
334 340
335 WebInspector.DOMStorageModel.prototype = { 341 WebInspector.DOMStorageModel.prototype = {
342 /**
343 * @param {DOMStorageAgent.StorageId} storageId
344 * @param {WebInspector.DOMStorage.Event} eventType
345 * @param {Object} eventData
346 */
347 domStorageModified: function(storageId, eventType, eventData)
pfeldman 2013/08/23 12:17:51 This can be private (private things are private to
348 {
349 var domStorage = this.storageForId(storageId);
350 if (!domStorage)
351 return;
352
353 domStorage.dispatchEventToListeners(eventType, eventData);
354 },
336 355
337 /** 356 /**
338 * @param {WebInspector.Event} event 357 * @param {WebInspector.Event} event
339 */ 358 */
340 _securityOriginAdded: function(event) 359 _securityOriginAdded: function(event)
341 { 360 {
342 var securityOrigin = /** @type {string} */ (event.data); 361 var securityOrigin = /** @type {string} */ (event.data);
343 var localStorageKey = this._storageKey(securityOrigin, true); 362 var localStorageKey = this._storageKey(securityOrigin, true);
344 console.assert(!this._storages[localStorageKey]); 363 console.assert(!this._storages[localStorageKey]);
345 var localStorage = new WebInspector.DOMStorage(securityOrigin, true); 364 var localStorage = new WebInspector.DOMStorage(securityOrigin, true);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 * @param {boolean} isLocalStorage 396 * @param {boolean} isLocalStorage
378 * @return {string} 397 * @return {string}
379 */ 398 */
380 _storageKey: function(securityOrigin, isLocalStorage) 399 _storageKey: function(securityOrigin, isLocalStorage)
381 { 400 {
382 return JSON.stringify(WebInspector.DOMStorage.storageId(securityOrigin, isLocalStorage)); 401 return JSON.stringify(WebInspector.DOMStorage.storageId(securityOrigin, isLocalStorage));
383 }, 402 },
384 403
385 /** 404 /**
386 * @param {DOMStorageAgent.StorageId} storageId 405 * @param {DOMStorageAgent.StorageId} storageId
387 */
388 _domStorageItemsCleared: function(storageId)
389 {
390 var domStorage = this.storageForId(storageId);
391 var storageData = {
392 storage: domStorage
393 };
394 this.dispatchEventToListeners(WebInspector.DOMStorageModel.Events.DOMSto rageItemsCleared, storageData);
pfeldman 2013/08/23 12:17:51 It looks like changing this with domStorage.dispat
vivekg__ 2013/08/23 13:19:37 Sounds great. Will revert this. Thanks!
395 },
396
397 /**
398 * @param {DOMStorageAgent.StorageId} storageId
399 * @param {string} key
400 */
401 _domStorageItemRemoved: function(storageId, key)
402 {
403 var domStorage = this.storageForId(storageId);
404 var storageData = {
405 storage: domStorage,
406 key: key
407 };
408 this.dispatchEventToListeners(WebInspector.DOMStorageModel.Events.DOMSto rageItemRemoved, storageData);
409 },
410
411 /**
412 * @param {DOMStorageAgent.StorageId} storageId
413 * @param {string} key
414 * @param {string} newValue
415 */
416 _domStorageItemAdded: function(storageId, key, newValue)
417 {
418 var domStorage = this.storageForId(storageId);
419 var storageData = {
420 storage: domStorage,
421 key: key,
422 newValue: newValue
423 };
424 this.dispatchEventToListeners(WebInspector.DOMStorageModel.Events.DOMSto rageItemAdded, storageData);
425 },
426
427 /**
428 * @param {DOMStorageAgent.StorageId} storageId
429 * @param {string} key
430 * @param {string} oldValue
431 * @param {string} newValue
432 */
433 _domStorageItemUpdated: function(storageId, key, oldValue, newValue)
434 {
435 var domStorage = this.storageForId(storageId);
436 var storageData = {
437 storage: domStorage,
438 key: key,
439 oldValue: oldValue,
440 newValue: newValue
441 };
442 this.dispatchEventToListeners(WebInspector.DOMStorageModel.Events.DOMSto rageItemUpdated, storageData);
443 },
444
445 /**
446 * @param {DOMStorageAgent.StorageId} storageId
447 * @return {WebInspector.DOMStorage} 406 * @return {WebInspector.DOMStorage}
448 */ 407 */
449 storageForId: function(storageId) 408 storageForId: function(storageId)
450 { 409 {
451 return this._storages[JSON.stringify(storageId)]; 410 return this._storages[JSON.stringify(storageId)];
452 }, 411 },
453 412
454 /** 413 /**
455 * @return {Array.<WebInspector.DOMStorage>} 414 * @return {Array.<WebInspector.DOMStorage>}
456 */ 415 */
(...skipping 18 matching lines...) Expand all
475 this._model = model; 434 this._model = model;
476 } 435 }
477 436
478 WebInspector.DOMStorageDispatcher.prototype = { 437 WebInspector.DOMStorageDispatcher.prototype = {
479 438
480 /** 439 /**
481 * @param {DOMStorageAgent.StorageId} storageId 440 * @param {DOMStorageAgent.StorageId} storageId
482 */ 441 */
483 domStorageItemsCleared: function(storageId) 442 domStorageItemsCleared: function(storageId)
484 { 443 {
485 this._model._domStorageItemsCleared(storageId); 444 var eventType = WebInspector.DOMStorage.Events.DOMStorageItemsCleared;
445 var eventData = {};
446 this._model.domStorageModified(storageId, eventType, eventData);
486 }, 447 },
487 448
488 /** 449 /**
489 * @param {DOMStorageAgent.StorageId} storageId 450 * @param {DOMStorageAgent.StorageId} storageId
490 * @param {string} key 451 * @param {string} key
491 */ 452 */
492 domStorageItemRemoved: function(storageId, key) 453 domStorageItemRemoved: function(storageId, key)
493 { 454 {
494 this._model._domStorageItemRemoved(storageId, key); 455 var eventType = WebInspector.DOMStorage.Events.DOMStorageItemRemoved;
456 var eventData = { key: key };
457 this._model.domStorageModified(storageId, eventType, eventData);
495 }, 458 },
496 459
497 /** 460 /**
498 * @param {DOMStorageAgent.StorageId} storageId 461 * @param {DOMStorageAgent.StorageId} storageId
499 * @param {string} key 462 * @param {string} key
500 * @param {string} newValue 463 * @param {string} value
501 */ 464 */
502 domStorageItemAdded: function(storageId, key, newValue) 465 domStorageItemAdded: function(storageId, key, value)
503 { 466 {
504 this._model._domStorageItemAdded(storageId, key, newValue); 467 var eventType = WebInspector.DOMStorage.Events.DOMStorageItemAdded;
468 var eventData = { key: key, value: value };
469 this._model.domStorageModified(storageId, eventType, eventData);
505 }, 470 },
506 471
507 /** 472 /**
508 * @param {DOMStorageAgent.StorageId} storageId 473 * @param {DOMStorageAgent.StorageId} storageId
509 * @param {string} key 474 * @param {string} key
510 * @param {string} oldValue 475 * @param {string} oldValue
511 * @param {string} newValue 476 * @param {string} value
512 */ 477 */
513 domStorageItemUpdated: function(storageId, key, oldValue, newValue) 478 domStorageItemUpdated: function(storageId, key, oldValue, value)
514 { 479 {
515 this._model._domStorageItemUpdated(storageId, key, oldValue, newValue); 480 var eventType = WebInspector.DOMStorage.Events.DOMStorageItemUpdated;
481 var eventData = { key: key, oldValue: oldValue, value: value };
482 this._model.domStorageModified(storageId, eventType, eventData);
516 }, 483 },
517 } 484 }
518 485
519 /** 486 /**
520 * @type {WebInspector.DOMStorageModel} 487 * @type {WebInspector.DOMStorageModel}
521 */ 488 */
522 WebInspector.domStorageModel = null; 489 WebInspector.domStorageModel = null;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698