| 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 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * @unrestricted | 30 * @unrestricted |
| 31 */ | 31 */ |
| 32 WebInspector.Database = class { | 32 Resources.Database = class { |
| 33 /** | 33 /** |
| 34 * @param {!WebInspector.DatabaseModel} model | 34 * @param {!Resources.DatabaseModel} model |
| 35 * @param {string} id | 35 * @param {string} id |
| 36 * @param {string} domain | 36 * @param {string} domain |
| 37 * @param {string} name | 37 * @param {string} name |
| 38 * @param {string} version | 38 * @param {string} version |
| 39 */ | 39 */ |
| 40 constructor(model, id, domain, name, version) { | 40 constructor(model, id, domain, name, version) { |
| 41 this._model = model; | 41 this._model = model; |
| 42 this._id = id; | 42 this._id = id; |
| 43 this._domain = domain; | 43 this._domain = domain; |
| 44 this._name = name; | 44 this._name = name; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 function callback(error, columnNames, values, errorObj) { | 106 function callback(error, columnNames, values, errorObj) { |
| 107 if (error) { | 107 if (error) { |
| 108 onError(error); | 108 onError(error); |
| 109 return; | 109 return; |
| 110 } | 110 } |
| 111 if (errorObj) { | 111 if (errorObj) { |
| 112 var message; | 112 var message; |
| 113 if (errorObj.message) | 113 if (errorObj.message) |
| 114 message = errorObj.message; | 114 message = errorObj.message; |
| 115 else if (errorObj.code === 2) | 115 else if (errorObj.code === 2) |
| 116 message = WebInspector.UIString('Database no longer has expected versi
on.'); | 116 message = Common.UIString('Database no longer has expected version.'); |
| 117 else | 117 else |
| 118 message = WebInspector.UIString('An unexpected error %s occurred.', er
rorObj.code); | 118 message = Common.UIString('An unexpected error %s occurred.', errorObj
.code); |
| 119 onError(message); | 119 onError(message); |
| 120 return; | 120 return; |
| 121 } | 121 } |
| 122 onSuccess(columnNames, values); | 122 onSuccess(columnNames, values); |
| 123 } | 123 } |
| 124 this._model._agent.executeSQL(this._id, query, callback); | 124 this._model._agent.executeSQL(this._id, query, callback); |
| 125 } | 125 } |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 /** | 128 /** |
| 129 * @unrestricted | 129 * @unrestricted |
| 130 */ | 130 */ |
| 131 WebInspector.DatabaseModel = class extends WebInspector.SDKModel { | 131 Resources.DatabaseModel = class extends SDK.SDKModel { |
| 132 /** | 132 /** |
| 133 * @param {!WebInspector.Target} target | 133 * @param {!SDK.Target} target |
| 134 */ | 134 */ |
| 135 constructor(target) { | 135 constructor(target) { |
| 136 super(WebInspector.DatabaseModel, target); | 136 super(Resources.DatabaseModel, target); |
| 137 | 137 |
| 138 this._databases = []; | 138 this._databases = []; |
| 139 this._agent = target.databaseAgent(); | 139 this._agent = target.databaseAgent(); |
| 140 this.target().registerDatabaseDispatcher(new WebInspector.DatabaseDispatcher
(this)); | 140 this.target().registerDatabaseDispatcher(new Resources.DatabaseDispatcher(th
is)); |
| 141 } | 141 } |
| 142 | 142 |
| 143 /** | 143 /** |
| 144 * @param {!WebInspector.Target} target | 144 * @param {!SDK.Target} target |
| 145 * @return {!WebInspector.DatabaseModel} | 145 * @return {!Resources.DatabaseModel} |
| 146 */ | 146 */ |
| 147 static fromTarget(target) { | 147 static fromTarget(target) { |
| 148 if (!target[WebInspector.DatabaseModel._symbol]) | 148 if (!target[Resources.DatabaseModel._symbol]) |
| 149 target[WebInspector.DatabaseModel._symbol] = new WebInspector.DatabaseMode
l(target); | 149 target[Resources.DatabaseModel._symbol] = new Resources.DatabaseModel(targ
et); |
| 150 | 150 |
| 151 return target[WebInspector.DatabaseModel._symbol]; | 151 return target[Resources.DatabaseModel._symbol]; |
| 152 } | 152 } |
| 153 | 153 |
| 154 enable() { | 154 enable() { |
| 155 if (this._enabled) | 155 if (this._enabled) |
| 156 return; | 156 return; |
| 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(WebInspector.DatabaseModel.Events.DatabasesRem
oved); | 167 this.dispatchEventToListeners(Resources.DatabaseModel.Events.DatabasesRemove
d); |
| 168 } | 168 } |
| 169 | 169 |
| 170 /** | 170 /** |
| 171 * @return {!Array.<!WebInspector.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 {!WebInspector.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(WebInspector.DatabaseModel.Events.DatabaseAdde
d, database); | 185 this.dispatchEventToListeners(Resources.DatabaseModel.Events.DatabaseAdded,
database); |
| 186 } | 186 } |
| 187 }; | 187 }; |
| 188 | 188 |
| 189 /** @enum {symbol} */ | 189 /** @enum {symbol} */ |
| 190 WebInspector.DatabaseModel.Events = { | 190 Resources.DatabaseModel.Events = { |
| 191 DatabaseAdded: Symbol('DatabaseAdded'), | 191 DatabaseAdded: Symbol('DatabaseAdded'), |
| 192 DatabasesRemoved: Symbol('DatabasesRemoved') | 192 DatabasesRemoved: Symbol('DatabasesRemoved') |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 /** | 195 /** |
| 196 * @implements {Protocol.DatabaseDispatcher} | 196 * @implements {Protocol.DatabaseDispatcher} |
| 197 * @unrestricted | 197 * @unrestricted |
| 198 */ | 198 */ |
| 199 WebInspector.DatabaseDispatcher = class { | 199 Resources.DatabaseDispatcher = class { |
| 200 /** | 200 /** |
| 201 * @param {!WebInspector.DatabaseModel} model | 201 * @param {!Resources.DatabaseModel} model |
| 202 */ | 202 */ |
| 203 constructor(model) { | 203 constructor(model) { |
| 204 this._model = model; | 204 this._model = model; |
| 205 } | 205 } |
| 206 | 206 |
| 207 /** | 207 /** |
| 208 * @override | 208 * @override |
| 209 * @param {!Protocol.Database.Database} payload | 209 * @param {!Protocol.Database.Database} payload |
| 210 */ | 210 */ |
| 211 addDatabase(payload) { | 211 addDatabase(payload) { |
| 212 this._model._addDatabase( | 212 this._model._addDatabase( |
| 213 new WebInspector.Database(this._model, payload.id, payload.domain, paylo
ad.name, payload.version)); | 213 new Resources.Database(this._model, payload.id, payload.domain, payload.
name, payload.version)); |
| 214 } | 214 } |
| 215 }; | 215 }; |
| 216 | 216 |
| 217 WebInspector.DatabaseModel._symbol = Symbol('DatabaseModel'); | 217 Resources.DatabaseModel._symbol = Symbol('DatabaseModel'); |
| OLD | NEW |