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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/common/Settings.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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 this._settingsStorage = storage; 37 this._settingsStorage = storage;
38 var clearLocalStorage = window.localStorage ? window.localStorage.clear.bind (window.localStorage) : undefined; 38 var clearLocalStorage = window.localStorage ? window.localStorage.clear.bind (window.localStorage) : undefined;
39 this._localStorage = new WebInspector.SettingsStorage(window.localStorage || {}, undefined, undefined, clearLocalStorage); 39 this._localStorage = new WebInspector.SettingsStorage(window.localStorage || {}, undefined, undefined, clearLocalStorage);
40 40
41 this._eventSupport = new WebInspector.Object(); 41 this._eventSupport = new WebInspector.Object();
42 /** @type {!Map<string, !WebInspector.Setting>} */ 42 /** @type {!Map<string, !WebInspector.Setting>} */
43 this._registry = new Map(); 43 this._registry = new Map();
44 /** @type {!Map<string, !WebInspector.Setting>} */ 44 /** @type {!Map<string, !WebInspector.Setting>} */
45 this._moduleSettings = new Map(); 45 this._moduleSettings = new Map();
46 self.runtime.extensions("setting").forEach(this._registerModuleSetting.bind( this)); 46 self.runtime.extensions("setting").forEach(this._registerModuleSetting.bind( this));
47 } 47 };
48 48
49 WebInspector.Settings.prototype = { 49 WebInspector.Settings.prototype = {
50 /** 50 /**
51 * @param {!Runtime.Extension} extension 51 * @param {!Runtime.Extension} extension
52 */ 52 */
53 _registerModuleSetting: function(extension) 53 _registerModuleSetting: function(extension)
54 { 54 {
55 var descriptor = extension.descriptor(); 55 var descriptor = extension.descriptor();
56 var settingName = descriptor["settingName"]; 56 var settingName = descriptor["settingName"];
57 var settingType = descriptor["settingType"]; 57 var settingType = descriptor["settingType"];
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 return /** @type {!WebInspector.RegExpSetting} */ (this._registry.get(ke y)); 122 return /** @type {!WebInspector.RegExpSetting} */ (this._registry.get(ke y));
123 }, 123 },
124 124
125 clearAll: function() 125 clearAll: function()
126 { 126 {
127 this._settingsStorage.removeAll(); 127 this._settingsStorage.removeAll();
128 this._localStorage.removeAll(); 128 this._localStorage.removeAll();
129 var versionSetting = WebInspector.settings.createSetting(WebInspector.Ve rsionController._currentVersionName, 0); 129 var versionSetting = WebInspector.settings.createSetting(WebInspector.Ve rsionController._currentVersionName, 0);
130 versionSetting.set(WebInspector.VersionController.currentVersion); 130 versionSetting.set(WebInspector.VersionController.currentVersion);
131 } 131 }
132 } 132 };
133 133
134 /** 134 /**
135 * @constructor 135 * @constructor
136 * @param {!Object} object 136 * @param {!Object} object
137 * @param {function(string, string)=} setCallback 137 * @param {function(string, string)=} setCallback
138 * @param {function(string)=} removeCallback 138 * @param {function(string)=} removeCallback
139 * @param {function(string)=} removeAllCallback 139 * @param {function(string)=} removeAllCallback
140 */ 140 */
141 WebInspector.SettingsStorage = function(object, setCallback, removeCallback, rem oveAllCallback) 141 WebInspector.SettingsStorage = function(object, setCallback, removeCallback, rem oveAllCallback)
142 { 142 {
143 this._object = object; 143 this._object = object;
144 this._setCallback = setCallback || function() {}; 144 this._setCallback = setCallback || function() {};
145 this._removeCallback = removeCallback || function() {}; 145 this._removeCallback = removeCallback || function() {};
146 this._removeAllCallback = removeAllCallback || function() {}; 146 this._removeAllCallback = removeAllCallback || function() {};
147 } 147 };
148 148
149 WebInspector.SettingsStorage.prototype = { 149 WebInspector.SettingsStorage.prototype = {
150 /** 150 /**
151 * @param {string} name 151 * @param {string} name
152 * @param {string} value 152 * @param {string} value
153 */ 153 */
154 set: function(name, value) 154 set: function(name, value)
155 { 155 {
156 this._object[name] = value; 156 this._object[name] = value;
157 this._setCallback(name, value); 157 this._setCallback(name, value);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 function comparator(key1, key2) 202 function comparator(key1, key2)
203 { 203 {
204 return sizes[key2] - sizes[key1]; 204 return sizes[key2] - sizes[key1];
205 } 205 }
206 206
207 keys.sort(comparator); 207 keys.sort(comparator);
208 208
209 for (var i = 0; i < 10 && i < keys.length; ++i) 209 for (var i = 0; i < 10 && i < keys.length; ++i)
210 WebInspector.console.log("Setting: '" + keys[i] + "', size: " + size s[keys[i]]); 210 WebInspector.console.log("Setting: '" + keys[i] + "', size: " + size s[keys[i]]);
211 } 211 }
212 } 212 };
213 213
214 /** 214 /**
215 * @constructor 215 * @constructor
216 * @param {!WebInspector.Settings} settings 216 * @param {!WebInspector.Settings} settings
217 * @param {string} name 217 * @param {string} name
218 * @param {V} defaultValue 218 * @param {V} defaultValue
219 * @param {!WebInspector.Object} eventSupport 219 * @param {!WebInspector.Object} eventSupport
220 * @param {!WebInspector.SettingsStorage} storage 220 * @param {!WebInspector.SettingsStorage} storage
221 * @template V 221 * @template V
222 */ 222 */
223 WebInspector.Setting = function(settings, name, defaultValue, eventSupport, stor age) 223 WebInspector.Setting = function(settings, name, defaultValue, eventSupport, stor age)
224 { 224 {
225 this._settings = settings; 225 this._settings = settings;
226 this._name = name; 226 this._name = name;
227 this._defaultValue = defaultValue; 227 this._defaultValue = defaultValue;
228 this._eventSupport = eventSupport; 228 this._eventSupport = eventSupport;
229 this._storage = storage; 229 this._storage = storage;
230 } 230 };
231 231
232 WebInspector.Setting.prototype = { 232 WebInspector.Setting.prototype = {
233 /** 233 /**
234 * @param {function(!WebInspector.Event)} listener 234 * @param {function(!WebInspector.Event)} listener
235 * @param {!Object=} thisObject 235 * @param {!Object=} thisObject
236 */ 236 */
237 addChangeListener: function(listener, thisObject) 237 addChangeListener: function(listener, thisObject)
238 { 238 {
239 this._eventSupport.addEventListener(this._name, listener, thisObject); 239 this._eventSupport.addEventListener(this._name, listener, thisObject);
240 }, 240 },
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 * @param {string} name 303 * @param {string} name
304 * @param {string} value 304 * @param {string} value
305 */ 305 */
306 _printSettingsSavingError: function(message, name, value) 306 _printSettingsSavingError: function(message, name, value)
307 { 307 {
308 var errorMessage = "Error saving setting with name: " + this._name + ", value length: " + value.length + ". Error: " + message; 308 var errorMessage = "Error saving setting with name: " + this._name + ", value length: " + value.length + ". Error: " + message;
309 console.error(errorMessage); 309 console.error(errorMessage);
310 WebInspector.console.error(errorMessage); 310 WebInspector.console.error(errorMessage);
311 this._storage._dumpSizes(); 311 this._storage._dumpSizes();
312 } 312 }
313 } 313 };
314 314
315 /** 315 /**
316 * @constructor 316 * @constructor
317 * @extends {WebInspector.Setting} 317 * @extends {WebInspector.Setting}
318 * @param {!WebInspector.Settings} settings 318 * @param {!WebInspector.Settings} settings
319 * @param {string} name 319 * @param {string} name
320 * @param {string} defaultValue 320 * @param {string} defaultValue
321 * @param {!WebInspector.Object} eventSupport 321 * @param {!WebInspector.Object} eventSupport
322 * @param {!WebInspector.SettingsStorage} storage 322 * @param {!WebInspector.SettingsStorage} storage
323 * @param {string=} regexFlags 323 * @param {string=} regexFlags
324 */ 324 */
325 WebInspector.RegExpSetting = function(settings, name, defaultValue, eventSupport , storage, regexFlags) 325 WebInspector.RegExpSetting = function(settings, name, defaultValue, eventSupport , storage, regexFlags)
326 { 326 {
327 WebInspector.Setting.call(this, settings, name, defaultValue ? [{ pattern: d efaultValue }] : [], eventSupport, storage); 327 WebInspector.Setting.call(this, settings, name, defaultValue ? [{ pattern: d efaultValue }] : [], eventSupport, storage);
328 this._regexFlags = regexFlags; 328 this._regexFlags = regexFlags;
329 } 329 };
330 330
331 WebInspector.RegExpSetting.prototype = { 331 WebInspector.RegExpSetting.prototype = {
332 /** 332 /**
333 * @override 333 * @override
334 * @return {string} 334 * @return {string}
335 */ 335 */
336 get: function() 336 get: function()
337 { 337 {
338 var result = []; 338 var result = [];
339 var items = this.getAsArray(); 339 var items = this.getAsArray();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 try { 382 try {
383 var pattern = this.get(); 383 var pattern = this.get();
384 if (pattern) 384 if (pattern)
385 this._regex = new RegExp(pattern, this._regexFlags || ""); 385 this._regex = new RegExp(pattern, this._regexFlags || "");
386 } catch (e) { 386 } catch (e) {
387 } 387 }
388 return this._regex; 388 return this._regex;
389 }, 389 },
390 390
391 __proto__: WebInspector.Setting.prototype 391 __proto__: WebInspector.Setting.prototype
392 } 392 };
393 393
394 /** 394 /**
395 * @constructor 395 * @constructor
396 */ 396 */
397 WebInspector.VersionController = function() 397 WebInspector.VersionController = function()
398 { 398 {
399 } 399 };
400 400
401 WebInspector.VersionController._currentVersionName = "inspectorVersion"; 401 WebInspector.VersionController._currentVersionName = "inspectorVersion";
402 WebInspector.VersionController.currentVersion = 20; 402 WebInspector.VersionController.currentVersion = 20;
403 403
404 WebInspector.VersionController.prototype = { 404 WebInspector.VersionController.prototype = {
405 updateVersion: function() 405 updateVersion: function()
406 { 406 {
407 var localStorageVersion = window.localStorage ? window.localStorage[WebI nspector.VersionController._currentVersionName] : 0; 407 var localStorageVersion = window.localStorage ? window.localStorage[WebI nspector.VersionController._currentVersionName] : 0;
408 var versionSetting = WebInspector.settings.createSetting(WebInspector.Ve rsionController._currentVersionName, 0); 408 var versionSetting = WebInspector.settings.createSetting(WebInspector.Ve rsionController._currentVersionName, 0);
409 var currentVersion = WebInspector.VersionController.currentVersion; 409 var currentVersion = WebInspector.VersionController.currentVersion;
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 * @param {!WebInspector.Setting} breakpointsSetting 756 * @param {!WebInspector.Setting} breakpointsSetting
757 * @param {number} maxBreakpointsCount 757 * @param {number} maxBreakpointsCount
758 */ 758 */
759 _clearBreakpointsWhenTooMany: function(breakpointsSetting, maxBreakpointsCou nt) 759 _clearBreakpointsWhenTooMany: function(breakpointsSetting, maxBreakpointsCou nt)
760 { 760 {
761 // If there are too many breakpoints in a storage, it is likely due to a recent bug that caused 761 // If there are too many breakpoints in a storage, it is likely due to a recent bug that caused
762 // periodical breakpoints duplication leading to inspector slowness. 762 // periodical breakpoints duplication leading to inspector slowness.
763 if (breakpointsSetting.get().length > maxBreakpointsCount) 763 if (breakpointsSetting.get().length > maxBreakpointsCount)
764 breakpointsSetting.set([]); 764 breakpointsSetting.set([]);
765 } 765 }
766 } 766 };
767 767
768 /** 768 /**
769 * @type {!WebInspector.Settings} 769 * @type {!WebInspector.Settings}
770 */ 770 */
771 WebInspector.settings; 771 WebInspector.settings;
772 772
773 /** 773 /**
774 * @param {string} settingName 774 * @param {string} settingName
775 * @return {!WebInspector.Setting} 775 * @return {!WebInspector.Setting}
776 */ 776 */
777 WebInspector.moduleSetting = function(settingName) 777 WebInspector.moduleSetting = function(settingName)
778 { 778 {
779 return WebInspector.settings.moduleSetting(settingName); 779 return WebInspector.settings.moduleSetting(settingName);
780 } 780 };
781 781
782 /** 782 /**
783 * @param {string} settingName 783 * @param {string} settingName
784 * @return {!WebInspector.Setting} 784 * @return {!WebInspector.Setting}
785 */ 785 */
786 WebInspector.settingForTest = function(settingName) 786 WebInspector.settingForTest = function(settingName)
787 { 787 {
788 return WebInspector.settings.settingForTest(settingName); 788 return WebInspector.settings.settingForTest(settingName);
789 } 789 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698