Chromium Code Reviews| Index: chrome/browser/resources/net_internals/util.js |
| =================================================================== |
| --- chrome/browser/resources/net_internals/util.js (revision 95298) |
| +++ chrome/browser/resources/net_internals/util.js (working copy) |
| @@ -143,6 +143,18 @@ |
| } |
| /** |
| + * Helper to make sure singleton classes are not instantiated more than once. |
| + */ |
| +function assertFirstConstructorCall(ctor) { |
|
eroman
2011/08/03 20:46:54
I added this as an extra bonus, since weird things
mmenke
2011/08/03 20:50:36
Good idea.
|
| + // This is the variable which is set by cr.addSingletonGetter(). |
| + if (ctor.hasCreateFirstInstance_) { |
| + throw Error('The class ' + ctor.name + ' is a singleton, and should ' + |
| + 'only be accessed using ' + ctor.name + '.getInstance().'); |
| + } |
| + ctor.hasCreateFirstInstance_ = true; |
| +} |
| + |
| +/** |
| * TablePrinter is a helper to format a table as ascii art or an HTML table. |
| * |
| * Usage: call addRow() and addCell() repeatedly to specify the data. |