OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 | 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 } // namespace | 192 } // namespace |
193 | 193 |
194 void InspectorDatabaseAgent::didOpenDatabase(PassRefPtrWillBeRawPtr<Database> da
tabase, const String& domain, const String& name, const String& version) | 194 void InspectorDatabaseAgent::didOpenDatabase(PassRefPtrWillBeRawPtr<Database> da
tabase, const String& domain, const String& name, const String& version) |
195 { | 195 { |
196 if (InspectorDatabaseResource* resource = findByFileName(database->fileName(
))) { | 196 if (InspectorDatabaseResource* resource = findByFileName(database->fileName(
))) { |
197 resource->setDatabase(database); | 197 resource->setDatabase(database); |
198 return; | 198 return; |
199 } | 199 } |
200 | 200 |
201 RefPtr<InspectorDatabaseResource> resource = InspectorDatabaseResource::crea
te(database, domain, name, version); | 201 RefPtrWillBeRawPtr<InspectorDatabaseResource> resource = InspectorDatabaseRe
source::create(database, domain, name, version); |
202 m_resources.set(resource->id(), resource); | 202 m_resources.set(resource->id(), resource); |
203 // Resources are only bound while visible. | 203 // Resources are only bound while visible. |
204 if (m_frontend && m_enabled) | 204 if (m_frontend && m_enabled) |
205 resource->bind(m_frontend); | 205 resource->bind(m_frontend); |
206 } | 206 } |
207 | 207 |
208 void InspectorDatabaseAgent::didCommitLoad(LocalFrame* frame, DocumentLoader* lo
ader) | 208 void InspectorDatabaseAgent::didCommitLoad(LocalFrame* frame, DocumentLoader* lo
ader) |
209 { | 209 { |
210 // FIXME: If "frame" is always guarenteed to be in the same Page as loader->
frame() | 210 // FIXME: If "frame" is always guarenteed to be in the same Page as loader->
frame() |
211 // then all we need to check here is loader->frame()->isMainFrame() | 211 // then all we need to check here is loader->frame()->isMainFrame() |
(...skipping 26 matching lines...) Expand all Loading... |
238 disable(0); | 238 disable(0); |
239 } | 239 } |
240 | 240 |
241 void InspectorDatabaseAgent::enable(ErrorString*) | 241 void InspectorDatabaseAgent::enable(ErrorString*) |
242 { | 242 { |
243 if (m_enabled) | 243 if (m_enabled) |
244 return; | 244 return; |
245 m_enabled = true; | 245 m_enabled = true; |
246 m_state->setBoolean(DatabaseAgentState::databaseAgentEnabled, m_enabled); | 246 m_state->setBoolean(DatabaseAgentState::databaseAgentEnabled, m_enabled); |
247 | 247 |
248 DatabaseResourcesMap::iterator databasesEnd = m_resources.end(); | 248 DatabaseResourcesHeapMap::iterator databasesEnd = m_resources.end(); |
249 for (DatabaseResourcesMap::iterator it = m_resources.begin(); it != database
sEnd; ++it) | 249 for (DatabaseResourcesHeapMap::iterator it = m_resources.begin(); it != data
basesEnd; ++it) |
250 it->value->bind(m_frontend); | 250 it->value->bind(m_frontend); |
251 } | 251 } |
252 | 252 |
253 void InspectorDatabaseAgent::disable(ErrorString*) | 253 void InspectorDatabaseAgent::disable(ErrorString*) |
254 { | 254 { |
255 if (!m_enabled) | 255 if (!m_enabled) |
256 return; | 256 return; |
257 m_enabled = false; | 257 m_enabled = false; |
258 m_state->setBoolean(DatabaseAgentState::databaseAgentEnabled, m_enabled); | 258 m_state->setBoolean(DatabaseAgentState::databaseAgentEnabled, m_enabled); |
259 } | 259 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 } | 297 } |
298 | 298 |
299 OwnPtr<SQLTransactionCallback> callback(TransactionCallback::create(query, r
equestCallback.get())); | 299 OwnPtr<SQLTransactionCallback> callback(TransactionCallback::create(query, r
equestCallback.get())); |
300 OwnPtr<SQLTransactionErrorCallback> errorCallback(TransactionErrorCallback::
create(requestCallback.get())); | 300 OwnPtr<SQLTransactionErrorCallback> errorCallback(TransactionErrorCallback::
create(requestCallback.get())); |
301 OwnPtr<VoidCallback> successCallback(TransactionSuccessCallback::create()); | 301 OwnPtr<VoidCallback> successCallback(TransactionSuccessCallback::create()); |
302 database->transaction(callback.release(), errorCallback.release(), successCa
llback.release()); | 302 database->transaction(callback.release(), errorCallback.release(), successCa
llback.release()); |
303 } | 303 } |
304 | 304 |
305 InspectorDatabaseResource* InspectorDatabaseAgent::findByFileName(const String&
fileName) | 305 InspectorDatabaseResource* InspectorDatabaseAgent::findByFileName(const String&
fileName) |
306 { | 306 { |
307 for (DatabaseResourcesMap::iterator it = m_resources.begin(); it != m_resour
ces.end(); ++it) { | 307 for (DatabaseResourcesHeapMap::iterator it = m_resources.begin(); it != m_re
sources.end(); ++it) { |
308 if (it->value->database()->fileName() == fileName) | 308 if (it->value->database()->fileName() == fileName) |
309 return it->value.get(); | 309 return it->value.get(); |
310 } | 310 } |
311 return 0; | 311 return 0; |
312 } | 312 } |
313 | 313 |
314 Database* InspectorDatabaseAgent::databaseForId(const String& databaseId) | 314 Database* InspectorDatabaseAgent::databaseForId(const String& databaseId) |
315 { | 315 { |
316 DatabaseResourcesMap::iterator it = m_resources.find(databaseId); | 316 DatabaseResourcesHeapMap::iterator it = m_resources.find(databaseId); |
317 if (it == m_resources.end()) | 317 if (it == m_resources.end()) |
318 return 0; | 318 return 0; |
319 return it->value->database(); | 319 return it->value->database(); |
320 } | 320 } |
321 | 321 |
322 } // namespace WebCore | 322 } // namespace WebCore |
OLD | NEW |