OLD | NEW |
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 23 matching lines...) Expand all Loading... |
34 * @param {string} name | 34 * @param {string} name |
35 * @param {string} version | 35 * @param {string} version |
36 */ | 36 */ |
37 WebInspector.Database = function(model, id, domain, name, version) | 37 WebInspector.Database = function(model, id, domain, name, version) |
38 { | 38 { |
39 this._model = model; | 39 this._model = model; |
40 this._id = id; | 40 this._id = id; |
41 this._domain = domain; | 41 this._domain = domain; |
42 this._name = name; | 42 this._name = name; |
43 this._version = version; | 43 this._version = version; |
44 } | 44 }; |
45 | 45 |
46 WebInspector.Database.prototype = { | 46 WebInspector.Database.prototype = { |
47 /** @return {string} */ | 47 /** @return {string} */ |
48 get id() | 48 get id() |
49 { | 49 { |
50 return this._id; | 50 return this._id; |
51 }, | 51 }, |
52 | 52 |
53 /** @return {string} */ | 53 /** @return {string} */ |
54 get name() | 54 get name() |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 message = WebInspector.UIString("Database no longer has expe
cted version."); | 123 message = WebInspector.UIString("Database no longer has expe
cted version."); |
124 else | 124 else |
125 message = WebInspector.UIString("An unexpected error %s occu
rred.", errorObj.code); | 125 message = WebInspector.UIString("An unexpected error %s occu
rred.", errorObj.code); |
126 onError(message); | 126 onError(message); |
127 return; | 127 return; |
128 } | 128 } |
129 onSuccess(columnNames, values); | 129 onSuccess(columnNames, values); |
130 } | 130 } |
131 this._model._agent.executeSQL(this._id, query, callback); | 131 this._model._agent.executeSQL(this._id, query, callback); |
132 } | 132 } |
133 } | 133 }; |
134 | 134 |
135 /** | 135 /** |
136 * @constructor | 136 * @constructor |
137 * @extends {WebInspector.SDKModel} | 137 * @extends {WebInspector.SDKModel} |
138 * @param {!WebInspector.Target} target | 138 * @param {!WebInspector.Target} target |
139 */ | 139 */ |
140 WebInspector.DatabaseModel = function(target) | 140 WebInspector.DatabaseModel = function(target) |
141 { | 141 { |
142 WebInspector.SDKModel.call(this, WebInspector.DatabaseModel, target); | 142 WebInspector.SDKModel.call(this, WebInspector.DatabaseModel, target); |
143 | 143 |
144 this._databases = []; | 144 this._databases = []; |
145 this._agent = target.databaseAgent(); | 145 this._agent = target.databaseAgent(); |
146 this.target().registerDatabaseDispatcher(new WebInspector.DatabaseDispatcher
(this)); | 146 this.target().registerDatabaseDispatcher(new WebInspector.DatabaseDispatcher
(this)); |
147 } | 147 }; |
148 | 148 |
149 /** @enum {symbol} */ | 149 /** @enum {symbol} */ |
150 WebInspector.DatabaseModel.Events = { | 150 WebInspector.DatabaseModel.Events = { |
151 DatabaseAdded: Symbol("DatabaseAdded"), | 151 DatabaseAdded: Symbol("DatabaseAdded"), |
152 DatabasesRemoved: Symbol("DatabasesRemoved") | 152 DatabasesRemoved: Symbol("DatabasesRemoved") |
153 } | 153 }; |
154 | 154 |
155 WebInspector.DatabaseModel.prototype = { | 155 WebInspector.DatabaseModel.prototype = { |
156 enable: function() | 156 enable: function() |
157 { | 157 { |
158 if (this._enabled) | 158 if (this._enabled) |
159 return; | 159 return; |
160 this._agent.enable(); | 160 this._agent.enable(); |
161 this._enabled = true; | 161 this._enabled = true; |
162 }, | 162 }, |
163 | 163 |
(...skipping 21 matching lines...) Expand all Loading... |
185 /** | 185 /** |
186 * @param {!WebInspector.Database} database | 186 * @param {!WebInspector.Database} database |
187 */ | 187 */ |
188 _addDatabase: function(database) | 188 _addDatabase: function(database) |
189 { | 189 { |
190 this._databases.push(database); | 190 this._databases.push(database); |
191 this.dispatchEventToListeners(WebInspector.DatabaseModel.Events.Database
Added, database); | 191 this.dispatchEventToListeners(WebInspector.DatabaseModel.Events.Database
Added, database); |
192 }, | 192 }, |
193 | 193 |
194 __proto__: WebInspector.SDKModel.prototype | 194 __proto__: WebInspector.SDKModel.prototype |
195 } | 195 }; |
196 | 196 |
197 /** | 197 /** |
198 * @constructor | 198 * @constructor |
199 * @implements {DatabaseAgent.Dispatcher} | 199 * @implements {DatabaseAgent.Dispatcher} |
200 * @param {!WebInspector.DatabaseModel} model | 200 * @param {!WebInspector.DatabaseModel} model |
201 */ | 201 */ |
202 WebInspector.DatabaseDispatcher = function(model) | 202 WebInspector.DatabaseDispatcher = function(model) |
203 { | 203 { |
204 this._model = model; | 204 this._model = model; |
205 } | 205 }; |
206 | 206 |
207 WebInspector.DatabaseDispatcher.prototype = { | 207 WebInspector.DatabaseDispatcher.prototype = { |
208 /** | 208 /** |
209 * @override | 209 * @override |
210 * @param {!DatabaseAgent.Database} payload | 210 * @param {!DatabaseAgent.Database} payload |
211 */ | 211 */ |
212 addDatabase: function(payload) | 212 addDatabase: function(payload) |
213 { | 213 { |
214 this._model._addDatabase(new WebInspector.Database( | 214 this._model._addDatabase(new WebInspector.Database( |
215 this._model, | 215 this._model, |
216 payload.id, | 216 payload.id, |
217 payload.domain, | 217 payload.domain, |
218 payload.name, | 218 payload.name, |
219 payload.version)); | 219 payload.version)); |
220 } | 220 } |
221 } | 221 }; |
222 | 222 |
223 WebInspector.DatabaseModel._symbol = Symbol("DatabaseModel"); | 223 WebInspector.DatabaseModel._symbol = Symbol("DatabaseModel"); |
224 /** | 224 /** |
225 * @param {!WebInspector.Target} target | 225 * @param {!WebInspector.Target} target |
226 * @return {!WebInspector.DatabaseModel} | 226 * @return {!WebInspector.DatabaseModel} |
227 */ | 227 */ |
228 WebInspector.DatabaseModel.fromTarget = function(target) | 228 WebInspector.DatabaseModel.fromTarget = function(target) |
229 { | 229 { |
230 if (!target[WebInspector.DatabaseModel._symbol]) | 230 if (!target[WebInspector.DatabaseModel._symbol]) |
231 target[WebInspector.DatabaseModel._symbol] = new WebInspector.DatabaseMo
del(target); | 231 target[WebInspector.DatabaseModel._symbol] = new WebInspector.DatabaseMo
del(target); |
232 | 232 |
233 return target[WebInspector.DatabaseModel._symbol]; | 233 return target[WebInspector.DatabaseModel._symbol]; |
234 } | 234 }; |
OLD | NEW |