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

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

Issue 2580673002: [DevTools] Introduce typed events. (Closed)
Patch Set: [DevTools] Introduce typed events. Created 4 years 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) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 this._agent.enable(); 157 this._agent.enable();
158 this._enabled = true; 158 this._enabled = true;
159 } 159 }
160 160
161 disable() { 161 disable() {
162 if (!this._enabled) 162 if (!this._enabled)
163 return; 163 return;
164 this._enabled = false; 164 this._enabled = false;
165 this._databases = []; 165 this._databases = [];
166 this._agent.disable(); 166 this._agent.disable();
167 this.dispatchEventToListeners(Resources.DatabaseModel.Events.DatabasesRemove d); 167 this.emit(new Resources.DatabaseModel.DatabasesRemovedEvent());
168 } 168 }
169 169
170 /** 170 /**
171 * @return {!Array.<!Resources.Database>} 171 * @return {!Array.<!Resources.Database>}
172 */ 172 */
173 databases() { 173 databases() {
174 var result = []; 174 var result = [];
175 for (var database of this._databases) 175 for (var database of this._databases)
176 result.push(database); 176 result.push(database);
177 return result; 177 return result;
178 } 178 }
179 179
180 /** 180 /**
181 * @param {!Resources.Database} database 181 * @param {!Resources.Database} database
182 */ 182 */
183 _addDatabase(database) { 183 _addDatabase(database) {
184 this._databases.push(database); 184 this._databases.push(database);
185 this.dispatchEventToListeners(Resources.DatabaseModel.Events.DatabaseAdded, database); 185 this.emit(new Resources.DatabaseModel.DatabaseAddedEvent(database));
186 } 186 }
187 }; 187 };
188 188
189 /** @enum {symbol} */ 189 Resources.DatabaseModel.DatabaseAddedEvent = class {
lushnikov 2016/12/15 04:28:59 maybe we can keep a list of events - it was extrem
dgozman 2016/12/16 04:17:46 JSCompiler didn't like it :-(
190 Resources.DatabaseModel.Events = { 190 /**
191 DatabaseAdded: Symbol('DatabaseAdded'), 191 * @param {!Resources.Database} database
192 DatabasesRemoved: Symbol('DatabasesRemoved') 192 */
193 constructor(database) {
194 this.database = database;
195 }
193 }; 196 };
194 197
198 Resources.DatabaseModel.DatabasesRemovedEvent = class {};
199
195 /** 200 /**
196 * @implements {Protocol.DatabaseDispatcher} 201 * @implements {Protocol.DatabaseDispatcher}
197 * @unrestricted 202 * @unrestricted
198 */ 203 */
199 Resources.DatabaseDispatcher = class { 204 Resources.DatabaseDispatcher = class {
200 /** 205 /**
201 * @param {!Resources.DatabaseModel} model 206 * @param {!Resources.DatabaseModel} model
202 */ 207 */
203 constructor(model) { 208 constructor(model) {
204 this._model = model; 209 this._model = model;
205 } 210 }
206 211
207 /** 212 /**
208 * @override 213 * @override
209 * @param {!Protocol.Database.Database} payload 214 * @param {!Protocol.Database.Database} payload
210 */ 215 */
211 addDatabase(payload) { 216 addDatabase(payload) {
212 this._model._addDatabase( 217 this._model._addDatabase(
213 new Resources.Database(this._model, payload.id, payload.domain, payload. name, payload.version)); 218 new Resources.Database(this._model, payload.id, payload.domain, payload. name, payload.version));
214 } 219 }
215 }; 220 };
216 221
217 Resources.DatabaseModel._symbol = Symbol('DatabaseModel'); 222 Resources.DatabaseModel._symbol = Symbol('DatabaseModel');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698