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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/resources/IndexedDBModel.js

Issue 2440953003: DevTools: use semicolons after each statement. (Closed)
Patch Set: rebaseline Created 4 years, 1 month 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 26 matching lines...) Expand all
37 WebInspector.IndexedDBModel = function(target, securityOriginManager) 37 WebInspector.IndexedDBModel = function(target, securityOriginManager)
38 { 38 {
39 WebInspector.SDKModel.call(this, WebInspector.IndexedDBModel, target); 39 WebInspector.SDKModel.call(this, WebInspector.IndexedDBModel, target);
40 this._securityOriginManager = securityOriginManager; 40 this._securityOriginManager = securityOriginManager;
41 this._agent = target.indexedDBAgent(); 41 this._agent = target.indexedDBAgent();
42 42
43 /** @type {!Map.<!WebInspector.IndexedDBModel.DatabaseId, !WebInspector.Inde xedDBModel.Database>} */ 43 /** @type {!Map.<!WebInspector.IndexedDBModel.DatabaseId, !WebInspector.Inde xedDBModel.Database>} */
44 this._databases = new Map(); 44 this._databases = new Map();
45 /** @type {!Object.<string, !Array.<string>>} */ 45 /** @type {!Object.<string, !Array.<string>>} */
46 this._databaseNamesBySecurityOrigin = {}; 46 this._databaseNamesBySecurityOrigin = {};
47 } 47 };
48 48
49 WebInspector.IndexedDBModel.KeyTypes = { 49 WebInspector.IndexedDBModel.KeyTypes = {
50 NumberType: "number", 50 NumberType: "number",
51 StringType: "string", 51 StringType: "string",
52 DateType: "date", 52 DateType: "date",
53 ArrayType: "array" 53 ArrayType: "array"
54 }; 54 };
55 55
56 WebInspector.IndexedDBModel.KeyPathTypes = { 56 WebInspector.IndexedDBModel.KeyPathTypes = {
57 NullType: "null", 57 NullType: "null",
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 for (var i = 0; i < idbKey.length; ++i) 94 for (var i = 0; i < idbKey.length; ++i)
95 key.array.push(WebInspector.IndexedDBModel.keyFromIDBKey(idbKey[ i])); 95 key.array.push(WebInspector.IndexedDBModel.keyFromIDBKey(idbKey[ i]));
96 type = WebInspector.IndexedDBModel.KeyTypes.ArrayType; 96 type = WebInspector.IndexedDBModel.KeyTypes.ArrayType;
97 } 97 }
98 break; 98 break;
99 default: 99 default:
100 return undefined; 100 return undefined;
101 } 101 }
102 key.type = /** @type {!IndexedDBAgent.KeyType<string>} */ (type); 102 key.type = /** @type {!IndexedDBAgent.KeyType<string>} */ (type);
103 return key; 103 return key;
104 } 104 };
105 105
106 /** 106 /**
107 * @param {?IDBKeyRange=} idbKeyRange 107 * @param {?IDBKeyRange=} idbKeyRange
108 * @return {?IndexedDBAgent.KeyRange} 108 * @return {?IndexedDBAgent.KeyRange}
109 * eturn {?{lower: ?Object, upper: ?Object, lowerOpen: *, upperOpen: *}} 109 * eturn {?{lower: ?Object, upper: ?Object, lowerOpen: *, upperOpen: *}}
110 */ 110 */
111 WebInspector.IndexedDBModel.keyRangeFromIDBKeyRange = function(idbKeyRange) 111 WebInspector.IndexedDBModel.keyRangeFromIDBKeyRange = function(idbKeyRange)
112 { 112 {
113 if (typeof idbKeyRange === "undefined" || idbKeyRange === null) 113 if (typeof idbKeyRange === "undefined" || idbKeyRange === null)
114 return null; 114 return null;
115 115
116 var keyRange = {}; 116 var keyRange = {};
117 keyRange.lower = WebInspector.IndexedDBModel.keyFromIDBKey(idbKeyRange.lower ); 117 keyRange.lower = WebInspector.IndexedDBModel.keyFromIDBKey(idbKeyRange.lower );
118 keyRange.upper = WebInspector.IndexedDBModel.keyFromIDBKey(idbKeyRange.upper ); 118 keyRange.upper = WebInspector.IndexedDBModel.keyFromIDBKey(idbKeyRange.upper );
119 keyRange.lowerOpen = !!idbKeyRange.lowerOpen; 119 keyRange.lowerOpen = !!idbKeyRange.lowerOpen;
120 keyRange.upperOpen = !!idbKeyRange.upperOpen; 120 keyRange.upperOpen = !!idbKeyRange.upperOpen;
121 return keyRange; 121 return keyRange;
122 } 122 };
123 123
124 /** 124 /**
125 * @param {!IndexedDBAgent.KeyPath} keyPath 125 * @param {!IndexedDBAgent.KeyPath} keyPath
126 * @return {?string|!Array.<string>|undefined} 126 * @return {?string|!Array.<string>|undefined}
127 */ 127 */
128 WebInspector.IndexedDBModel.idbKeyPathFromKeyPath = function(keyPath) 128 WebInspector.IndexedDBModel.idbKeyPathFromKeyPath = function(keyPath)
129 { 129 {
130 var idbKeyPath; 130 var idbKeyPath;
131 switch (keyPath.type) { 131 switch (keyPath.type) {
132 case WebInspector.IndexedDBModel.KeyPathTypes.NullType: 132 case WebInspector.IndexedDBModel.KeyPathTypes.NullType:
133 idbKeyPath = null; 133 idbKeyPath = null;
134 break; 134 break;
135 case WebInspector.IndexedDBModel.KeyPathTypes.StringType: 135 case WebInspector.IndexedDBModel.KeyPathTypes.StringType:
136 idbKeyPath = keyPath.string; 136 idbKeyPath = keyPath.string;
137 break; 137 break;
138 case WebInspector.IndexedDBModel.KeyPathTypes.ArrayType: 138 case WebInspector.IndexedDBModel.KeyPathTypes.ArrayType:
139 idbKeyPath = keyPath.array; 139 idbKeyPath = keyPath.array;
140 break; 140 break;
141 } 141 }
142 return idbKeyPath; 142 return idbKeyPath;
143 } 143 };
144 144
145 /** 145 /**
146 * @param {?string|!Array.<string>|undefined} idbKeyPath 146 * @param {?string|!Array.<string>|undefined} idbKeyPath
147 * @return {?string} 147 * @return {?string}
148 */ 148 */
149 WebInspector.IndexedDBModel.keyPathStringFromIDBKeyPath = function(idbKeyPath) 149 WebInspector.IndexedDBModel.keyPathStringFromIDBKeyPath = function(idbKeyPath)
150 { 150 {
151 if (typeof idbKeyPath === "string") 151 if (typeof idbKeyPath === "string")
152 return "\"" + idbKeyPath + "\""; 152 return "\"" + idbKeyPath + "\"";
153 if (idbKeyPath instanceof Array) 153 if (idbKeyPath instanceof Array)
154 return "[\"" + idbKeyPath.join("\", \"") + "\"]"; 154 return "[\"" + idbKeyPath.join("\", \"") + "\"]";
155 return null; 155 return null;
156 } 156 };
157 157
158 /** @enum {symbol} */ 158 /** @enum {symbol} */
159 WebInspector.IndexedDBModel.Events = { 159 WebInspector.IndexedDBModel.Events = {
160 DatabaseAdded: Symbol("DatabaseAdded"), 160 DatabaseAdded: Symbol("DatabaseAdded"),
161 DatabaseRemoved: Symbol("DatabaseRemoved"), 161 DatabaseRemoved: Symbol("DatabaseRemoved"),
162 DatabaseLoaded: Symbol("DatabaseLoaded") 162 DatabaseLoaded: Symbol("DatabaseLoaded")
163 } 163 };
164 164
165 WebInspector.IndexedDBModel.prototype = { 165 WebInspector.IndexedDBModel.prototype = {
166 enable: function() 166 enable: function()
167 { 167 {
168 if (this._enabled) 168 if (this._enabled)
169 return; 169 return;
170 170
171 this._agent.enable(); 171 this._agent.enable();
172 this._securityOriginManager.addEventListener(WebInspector.SecurityOrigin Manager.Events.SecurityOriginAdded, this._securityOriginAdded, this); 172 this._securityOriginManager.addEventListener(WebInspector.SecurityOrigin Manager.Events.SecurityOriginAdded, this._securityOriginAdded, this);
173 this._securityOriginManager.addEventListener(WebInspector.SecurityOrigin Manager.Events.SecurityOriginRemoved, this._securityOriginRemoved, this); 173 this._securityOriginManager.addEventListener(WebInspector.SecurityOrigin Manager.Events.SecurityOriginRemoved, this._securityOriginRemoved, this);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 entries.push(new WebInspector.IndexedDBModel.Entry(key, primaryK ey, value)); 436 entries.push(new WebInspector.IndexedDBModel.Entry(key, primaryK ey, value));
437 } 437 }
438 callback(entries, hasMore); 438 callback(entries, hasMore);
439 } 439 }
440 440
441 var keyRange = WebInspector.IndexedDBModel.keyRangeFromIDBKeyRange(idbKe yRange); 441 var keyRange = WebInspector.IndexedDBModel.keyRangeFromIDBKeyRange(idbKe yRange);
442 this._agent.requestData(databaseId.securityOrigin, databaseName, objectS toreName, indexName, skipCount, pageSize, keyRange ? keyRange : undefined, inner Callback.bind(this)); 442 this._agent.requestData(databaseId.securityOrigin, databaseName, objectS toreName, indexName, skipCount, pageSize, keyRange ? keyRange : undefined, inner Callback.bind(this));
443 }, 443 },
444 444
445 __proto__: WebInspector.SDKModel.prototype 445 __proto__: WebInspector.SDKModel.prototype
446 } 446 };
447 447
448 /** 448 /**
449 * @constructor 449 * @constructor
450 * @param {!WebInspector.RemoteObject} key 450 * @param {!WebInspector.RemoteObject} key
451 * @param {!WebInspector.RemoteObject} primaryKey 451 * @param {!WebInspector.RemoteObject} primaryKey
452 * @param {!WebInspector.RemoteObject} value 452 * @param {!WebInspector.RemoteObject} value
453 */ 453 */
454 WebInspector.IndexedDBModel.Entry = function(key, primaryKey, value) 454 WebInspector.IndexedDBModel.Entry = function(key, primaryKey, value)
455 { 455 {
456 this.key = key; 456 this.key = key;
457 this.primaryKey = primaryKey; 457 this.primaryKey = primaryKey;
458 this.value = value; 458 this.value = value;
459 } 459 };
460 460
461 /** 461 /**
462 * @constructor 462 * @constructor
463 * @param {string} securityOrigin 463 * @param {string} securityOrigin
464 * @param {string} name 464 * @param {string} name
465 */ 465 */
466 WebInspector.IndexedDBModel.DatabaseId = function(securityOrigin, name) 466 WebInspector.IndexedDBModel.DatabaseId = function(securityOrigin, name)
467 { 467 {
468 this.securityOrigin = securityOrigin; 468 this.securityOrigin = securityOrigin;
469 this.name = name; 469 this.name = name;
470 } 470 };
471 471
472 WebInspector.IndexedDBModel.DatabaseId.prototype = { 472 WebInspector.IndexedDBModel.DatabaseId.prototype = {
473 /** 473 /**
474 * @param {!WebInspector.IndexedDBModel.DatabaseId} databaseId 474 * @param {!WebInspector.IndexedDBModel.DatabaseId} databaseId
475 * @return {boolean} 475 * @return {boolean}
476 */ 476 */
477 equals: function(databaseId) 477 equals: function(databaseId)
478 { 478 {
479 return this.name === databaseId.name && this.securityOrigin === database Id.securityOrigin; 479 return this.name === databaseId.name && this.securityOrigin === database Id.securityOrigin;
480 }, 480 },
481 } 481 };
482 /** 482 /**
483 * @constructor 483 * @constructor
484 * @param {!WebInspector.IndexedDBModel.DatabaseId} databaseId 484 * @param {!WebInspector.IndexedDBModel.DatabaseId} databaseId
485 * @param {number} version 485 * @param {number} version
486 */ 486 */
487 WebInspector.IndexedDBModel.Database = function(databaseId, version) 487 WebInspector.IndexedDBModel.Database = function(databaseId, version)
488 { 488 {
489 this.databaseId = databaseId; 489 this.databaseId = databaseId;
490 this.version = version; 490 this.version = version;
491 this.objectStores = {}; 491 this.objectStores = {};
492 } 492 };
493 493
494 /** 494 /**
495 * @constructor 495 * @constructor
496 * @param {string} name 496 * @param {string} name
497 * @param {*} keyPath 497 * @param {*} keyPath
498 * @param {boolean} autoIncrement 498 * @param {boolean} autoIncrement
499 */ 499 */
500 WebInspector.IndexedDBModel.ObjectStore = function(name, keyPath, autoIncrement) 500 WebInspector.IndexedDBModel.ObjectStore = function(name, keyPath, autoIncrement)
501 { 501 {
502 this.name = name; 502 this.name = name;
503 this.keyPath = keyPath; 503 this.keyPath = keyPath;
504 this.autoIncrement = autoIncrement; 504 this.autoIncrement = autoIncrement;
505 this.indexes = {}; 505 this.indexes = {};
506 } 506 };
507 507
508 WebInspector.IndexedDBModel.ObjectStore.prototype = { 508 WebInspector.IndexedDBModel.ObjectStore.prototype = {
509 /** 509 /**
510 * @type {string} 510 * @type {string}
511 */ 511 */
512 get keyPathString() 512 get keyPathString()
513 { 513 {
514 return WebInspector.IndexedDBModel.keyPathStringFromIDBKeyPath(this.keyP ath); 514 return WebInspector.IndexedDBModel.keyPathStringFromIDBKeyPath(this.keyP ath);
515 } 515 }
516 } 516 };
517 517
518 /** 518 /**
519 * @constructor 519 * @constructor
520 * @param {string} name 520 * @param {string} name
521 * @param {*} keyPath 521 * @param {*} keyPath
522 * @param {boolean} unique 522 * @param {boolean} unique
523 * @param {boolean} multiEntry 523 * @param {boolean} multiEntry
524 */ 524 */
525 WebInspector.IndexedDBModel.Index = function(name, keyPath, unique, multiEntry) 525 WebInspector.IndexedDBModel.Index = function(name, keyPath, unique, multiEntry)
526 { 526 {
527 this.name = name; 527 this.name = name;
528 this.keyPath = keyPath; 528 this.keyPath = keyPath;
529 this.unique = unique; 529 this.unique = unique;
530 this.multiEntry = multiEntry; 530 this.multiEntry = multiEntry;
531 } 531 };
532 532
533 WebInspector.IndexedDBModel.Index.prototype = { 533 WebInspector.IndexedDBModel.Index.prototype = {
534 /** 534 /**
535 * @type {string} 535 * @type {string}
536 */ 536 */
537 get keyPathString() 537 get keyPathString()
538 { 538 {
539 return WebInspector.IndexedDBModel.keyPathStringFromIDBKeyPath(this.keyP ath); 539 return WebInspector.IndexedDBModel.keyPathStringFromIDBKeyPath(this.keyP ath);
540 } 540 }
541 } 541 };
542 542
543 /** 543 /**
544 * @param {!WebInspector.Target} target 544 * @param {!WebInspector.Target} target
545 * @return {!WebInspector.IndexedDBModel} 545 * @return {!WebInspector.IndexedDBModel}
546 */ 546 */
547 WebInspector.IndexedDBModel.fromTarget = function(target) 547 WebInspector.IndexedDBModel.fromTarget = function(target)
548 { 548 {
549 var model = /** @type {?WebInspector.IndexedDBModel} */ (target.model(WebIns pector.IndexedDBModel)); 549 var model = /** @type {?WebInspector.IndexedDBModel} */ (target.model(WebIns pector.IndexedDBModel));
550 if (!model) 550 if (!model)
551 model = new WebInspector.IndexedDBModel(target, WebInspector.SecurityOri ginManager.fromTarget(target)); 551 model = new WebInspector.IndexedDBModel(target, WebInspector.SecurityOri ginManager.fromTarget(target));
552 return model; 552 return model;
553 } 553 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698