| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 | 32 |
| 33 #include "core/inspector/InspectorIndexedDBAgent.h" | 33 #include "core/inspector/InspectorIndexedDBAgent.h" |
| 34 | 34 |
| 35 #include "bindings/v8/ExceptionState.h" |
| 36 #include "bindings/v8/ExceptionStatePlaceholder.h" |
| 35 #include "bindings/v8/ScriptController.h" | 37 #include "bindings/v8/ScriptController.h" |
| 36 #include "core/dom/DOMStringList.h" | 38 #include "core/dom/DOMStringList.h" |
| 37 #include "core/dom/Document.h" | 39 #include "core/dom/Document.h" |
| 38 #include "core/dom/Event.h" | 40 #include "core/dom/Event.h" |
| 39 #include "core/dom/EventListener.h" | 41 #include "core/dom/EventListener.h" |
| 40 #include "core/inspector/InjectedScript.h" | 42 #include "core/inspector/InjectedScript.h" |
| 41 #include "core/inspector/InspectorPageAgent.h" | 43 #include "core/inspector/InspectorPageAgent.h" |
| 42 #include "core/inspector/InspectorState.h" | 44 #include "core/inspector/InspectorState.h" |
| 43 #include "core/page/Frame.h" | 45 #include "core/page/Frame.h" |
| 44 #include "core/platform/JSONValues.h" | 46 #include "core/platform/JSONValues.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 virtual void handleEvent(ScriptExecutionContext*, Event* event) OVERRIDE | 104 virtual void handleEvent(ScriptExecutionContext*, Event* event) OVERRIDE |
| 103 { | 105 { |
| 104 if (!m_requestCallback->isActive()) | 106 if (!m_requestCallback->isActive()) |
| 105 return; | 107 return; |
| 106 if (event->type() != eventNames().successEvent) { | 108 if (event->type() != eventNames().successEvent) { |
| 107 m_requestCallback->sendFailure("Unexpected event type."); | 109 m_requestCallback->sendFailure("Unexpected event type."); |
| 108 return; | 110 return; |
| 109 } | 111 } |
| 110 | 112 |
| 111 IDBRequest* idbRequest = static_cast<IDBRequest*>(event->target()); | 113 IDBRequest* idbRequest = static_cast<IDBRequest*>(event->target()); |
| 112 ExceptionCode ec = 0; | 114 NonThrowExceptionState es; |
| 113 RefPtr<IDBAny> requestResult = idbRequest->result(ec); | 115 RefPtr<IDBAny> requestResult = idbRequest->result(es); |
| 114 if (ec) { | 116 if (es.hadException()) { |
| 115 m_requestCallback->sendFailure("Could not get result in callback."); | 117 m_requestCallback->sendFailure("Could not get result in callback."); |
| 116 return; | 118 return; |
| 117 } | 119 } |
| 118 if (requestResult->type() != IDBAny::DOMStringListType) { | 120 if (requestResult->type() != IDBAny::DOMStringListType) { |
| 119 m_requestCallback->sendFailure("Unexpected result type."); | 121 m_requestCallback->sendFailure("Unexpected result type."); |
| 120 return; | 122 return; |
| 121 } | 123 } |
| 122 | 124 |
| 123 RefPtr<DOMStringList> databaseNamesList = requestResult->domStringList()
; | 125 RefPtr<DOMStringList> databaseNamesList = requestResult->domStringList()
; |
| 124 RefPtr<TypeBuilder::Array<String> > databaseNames = TypeBuilder::Array<S
tring>::create(); | 126 RefPtr<TypeBuilder::Array<String> > databaseNames = TypeBuilder::Array<S
tring>::create(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 166 } |
| 165 | 167 |
| 166 virtual void handleEvent(ScriptExecutionContext*, Event* event) OVERRIDE | 168 virtual void handleEvent(ScriptExecutionContext*, Event* event) OVERRIDE |
| 167 { | 169 { |
| 168 if (event->type() != eventNames().successEvent) { | 170 if (event->type() != eventNames().successEvent) { |
| 169 m_executableWithDatabase->requestCallback()->sendFailure("Unexpected
event type."); | 171 m_executableWithDatabase->requestCallback()->sendFailure("Unexpected
event type."); |
| 170 return; | 172 return; |
| 171 } | 173 } |
| 172 | 174 |
| 173 IDBOpenDBRequest* idbOpenDBRequest = static_cast<IDBOpenDBRequest*>(even
t->target()); | 175 IDBOpenDBRequest* idbOpenDBRequest = static_cast<IDBOpenDBRequest*>(even
t->target()); |
| 174 ExceptionCode ec = 0; | 176 NonThrowExceptionState es; |
| 175 RefPtr<IDBAny> requestResult = idbOpenDBRequest->result(ec); | 177 RefPtr<IDBAny> requestResult = idbOpenDBRequest->result(es); |
| 176 if (ec) { | 178 if (es.hadException()) { |
| 177 m_executableWithDatabase->requestCallback()->sendFailure("Could not
get result in callback."); | 179 m_executableWithDatabase->requestCallback()->sendFailure("Could not
get result in callback."); |
| 178 return; | 180 return; |
| 179 } | 181 } |
| 180 if (requestResult->type() != IDBAny::IDBDatabaseType) { | 182 if (requestResult->type() != IDBAny::IDBDatabaseType) { |
| 181 m_executableWithDatabase->requestCallback()->sendFailure("Unexpected
result type."); | 183 m_executableWithDatabase->requestCallback()->sendFailure("Unexpected
result type."); |
| 182 return; | 184 return; |
| 183 } | 185 } |
| 184 | 186 |
| 185 RefPtr<IDBDatabase> idbDatabase = requestResult->idbDatabase(); | 187 RefPtr<IDBDatabase> idbDatabase = requestResult->idbDatabase(); |
| 186 m_executableWithDatabase->execute(idbDatabase); | 188 m_executableWithDatabase->execute(idbDatabase); |
| 187 IDBPendingTransactionMonitor::deactivateNewTransactions(); | 189 IDBPendingTransactionMonitor::deactivateNewTransactions(); |
| 188 idbDatabase->close(); | 190 idbDatabase->close(); |
| 189 } | 191 } |
| 190 | 192 |
| 191 private: | 193 private: |
| 192 OpenDatabaseCallback(ExecutableWithDatabase* executableWithDatabase) | 194 OpenDatabaseCallback(ExecutableWithDatabase* executableWithDatabase) |
| 193 : EventListener(EventListener::CPPEventListenerType) | 195 : EventListener(EventListener::CPPEventListenerType) |
| 194 , m_executableWithDatabase(executableWithDatabase) { } | 196 , m_executableWithDatabase(executableWithDatabase) { } |
| 195 RefPtr<ExecutableWithDatabase> m_executableWithDatabase; | 197 RefPtr<ExecutableWithDatabase> m_executableWithDatabase; |
| 196 }; | 198 }; |
| 197 | 199 |
| 198 void ExecutableWithDatabase::start(IDBFactory* idbFactory, SecurityOrigin*, cons
t String& databaseName) | 200 void ExecutableWithDatabase::start(IDBFactory* idbFactory, SecurityOrigin*, cons
t String& databaseName) |
| 199 { | 201 { |
| 200 RefPtr<OpenDatabaseCallback> callback = OpenDatabaseCallback::create(this); | 202 RefPtr<OpenDatabaseCallback> callback = OpenDatabaseCallback::create(this); |
| 201 ExceptionCode ec = 0; | 203 NonThrowExceptionState es; |
| 202 RefPtr<IDBOpenDBRequest> idbOpenDBRequest = idbFactory->open(context(), data
baseName, ec); | 204 RefPtr<IDBOpenDBRequest> idbOpenDBRequest = idbFactory->open(context(), data
baseName, es); |
| 203 if (ec) { | 205 if (es.hadException()) { |
| 204 requestCallback()->sendFailure("Could not open database."); | 206 requestCallback()->sendFailure("Could not open database."); |
| 205 return; | 207 return; |
| 206 } | 208 } |
| 207 idbOpenDBRequest->addEventListener(eventNames().successEvent, callback, fals
e); | 209 idbOpenDBRequest->addEventListener(eventNames().successEvent, callback, fals
e); |
| 208 } | 210 } |
| 209 | 211 |
| 210 static PassRefPtr<IDBTransaction> transactionForDatabase(ScriptExecutionContext*
scriptExecutionContext, IDBDatabase* idbDatabase, const String& objectStoreName
, const String& mode = IDBTransaction::modeReadOnly()) | 212 static PassRefPtr<IDBTransaction> transactionForDatabase(ScriptExecutionContext*
scriptExecutionContext, IDBDatabase* idbDatabase, const String& objectStoreName
, const String& mode = IDBTransaction::modeReadOnly()) |
| 211 { | 213 { |
| 212 ExceptionCode ec = 0; | 214 NonThrowExceptionState es; |
| 213 RefPtr<IDBTransaction> idbTransaction = idbDatabase->transaction(scriptExecu
tionContext, objectStoreName, mode, ec); | 215 RefPtr<IDBTransaction> idbTransaction = idbDatabase->transaction(scriptExecu
tionContext, objectStoreName, mode, es); |
| 214 if (ec) | 216 if (es.hadException()) |
| 215 return 0; | 217 return 0; |
| 216 return idbTransaction; | 218 return idbTransaction; |
| 217 } | 219 } |
| 218 | 220 |
| 219 static PassRefPtr<IDBObjectStore> objectStoreForTransaction(IDBTransaction* idbT
ransaction, const String& objectStoreName) | 221 static PassRefPtr<IDBObjectStore> objectStoreForTransaction(IDBTransaction* idbT
ransaction, const String& objectStoreName) |
| 220 { | 222 { |
| 221 ExceptionCode ec = 0; | 223 NonThrowExceptionState es; |
| 222 RefPtr<IDBObjectStore> idbObjectStore = idbTransaction->objectStore(objectSt
oreName, ec); | 224 RefPtr<IDBObjectStore> idbObjectStore = idbTransaction->objectStore(objectSt
oreName, es); |
| 223 if (ec) | 225 if (es.hadException()) |
| 224 return 0; | 226 return 0; |
| 225 return idbObjectStore; | 227 return idbObjectStore; |
| 226 } | 228 } |
| 227 | 229 |
| 228 static PassRefPtr<IDBIndex> indexForObjectStore(IDBObjectStore* idbObjectStore,
const String& indexName) | 230 static PassRefPtr<IDBIndex> indexForObjectStore(IDBObjectStore* idbObjectStore,
const String& indexName) |
| 229 { | 231 { |
| 230 ExceptionCode ec = 0; | 232 NonThrowExceptionState es; |
| 231 RefPtr<IDBIndex> idbIndex = idbObjectStore->index(indexName, ec); | 233 RefPtr<IDBIndex> idbIndex = idbObjectStore->index(indexName, es); |
| 232 if (ec) | 234 if (es.hadException()) |
| 233 return 0; | 235 return 0; |
| 234 return idbIndex; | 236 return idbIndex; |
| 235 } | 237 } |
| 236 | 238 |
| 237 static PassRefPtr<KeyPath> keyPathFromIDBKeyPath(const IDBKeyPath& idbKeyPath) | 239 static PassRefPtr<KeyPath> keyPathFromIDBKeyPath(const IDBKeyPath& idbKeyPath) |
| 238 { | 240 { |
| 239 RefPtr<KeyPath> keyPath; | 241 RefPtr<KeyPath> keyPath; |
| 240 switch (idbKeyPath.type()) { | 242 switch (idbKeyPath.type()) { |
| 241 case IDBKeyPath::NullType: | 243 case IDBKeyPath::NullType: |
| 242 keyPath = KeyPath::create().setType(KeyPath::Type::Null); | 244 keyPath = KeyPath::create().setType(KeyPath::Type::Null); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 } | 410 } |
| 409 | 411 |
| 410 virtual void handleEvent(ScriptExecutionContext*, Event* event) OVERRIDE | 412 virtual void handleEvent(ScriptExecutionContext*, Event* event) OVERRIDE |
| 411 { | 413 { |
| 412 if (event->type() != eventNames().successEvent) { | 414 if (event->type() != eventNames().successEvent) { |
| 413 m_requestCallback->sendFailure("Unexpected event type."); | 415 m_requestCallback->sendFailure("Unexpected event type."); |
| 414 return; | 416 return; |
| 415 } | 417 } |
| 416 | 418 |
| 417 IDBRequest* idbRequest = static_cast<IDBRequest*>(event->target()); | 419 IDBRequest* idbRequest = static_cast<IDBRequest*>(event->target()); |
| 418 ExceptionCode ec = 0; | 420 NonThrowExceptionState es; |
| 419 RefPtr<IDBAny> requestResult = idbRequest->result(ec); | 421 RefPtr<IDBAny> requestResult = idbRequest->result(es); |
| 420 if (ec) { | 422 if (es.hadException()) { |
| 421 m_requestCallback->sendFailure("Could not get result in callback."); | 423 m_requestCallback->sendFailure("Could not get result in callback."); |
| 422 return; | 424 return; |
| 423 } | 425 } |
| 424 if (requestResult->type() == IDBAny::ScriptValueType) { | 426 if (requestResult->type() == IDBAny::ScriptValueType) { |
| 425 end(false); | 427 end(false); |
| 426 return; | 428 return; |
| 427 } | 429 } |
| 428 if (requestResult->type() != IDBAny::IDBCursorWithValueType) { | 430 if (requestResult->type() != IDBAny::IDBCursorWithValueType) { |
| 429 m_requestCallback->sendFailure("Unexpected result type."); | 431 m_requestCallback->sendFailure("Unexpected result type."); |
| 430 return; | 432 return; |
| 431 } | 433 } |
| 432 | 434 |
| 433 RefPtr<IDBCursorWithValue> idbCursor = requestResult->idbCursorWithValue
(); | 435 RefPtr<IDBCursorWithValue> idbCursor = requestResult->idbCursorWithValue
(); |
| 434 | 436 |
| 435 if (m_skipCount) { | 437 if (m_skipCount) { |
| 436 ExceptionCode ec = 0; | 438 NonThrowExceptionState es; |
| 437 idbCursor->advance(m_skipCount, ec); | 439 idbCursor->advance(m_skipCount, es); |
| 438 if (ec) | 440 if (es.hadException()) |
| 439 m_requestCallback->sendFailure("Could not advance cursor."); | 441 m_requestCallback->sendFailure("Could not advance cursor."); |
| 440 m_skipCount = 0; | 442 m_skipCount = 0; |
| 441 return; | 443 return; |
| 442 } | 444 } |
| 443 | 445 |
| 444 if (m_result->length() == m_pageSize) { | 446 if (m_result->length() == m_pageSize) { |
| 445 end(true); | 447 end(true); |
| 446 return; | 448 return; |
| 447 } | 449 } |
| 448 | 450 |
| 449 // Continue cursor before making injected script calls, otherwise transa
ction might be finished. | 451 // Continue cursor before making injected script calls, otherwise transa
ction might be finished. |
| 450 idbCursor->continueFunction(0, ec); | 452 idbCursor->continueFunction(0, es); |
| 451 if (ec) { | 453 if (es.hadException()) { |
| 452 m_requestCallback->sendFailure("Could not continue cursor."); | 454 m_requestCallback->sendFailure("Could not continue cursor."); |
| 453 return; | 455 return; |
| 454 } | 456 } |
| 455 | 457 |
| 456 RefPtr<DataEntry> dataEntry = DataEntry::create() | 458 RefPtr<DataEntry> dataEntry = DataEntry::create() |
| 457 .setKey(m_injectedScript.wrapObject(idbCursor->key(), String())) | 459 .setKey(m_injectedScript.wrapObject(idbCursor->key(), String())) |
| 458 .setPrimaryKey(m_injectedScript.wrapObject(idbCursor->primaryKey(),
String())) | 460 .setPrimaryKey(m_injectedScript.wrapObject(idbCursor->primaryKey(),
String())) |
| 459 .setValue(m_injectedScript.wrapObject(idbCursor->value(), String()))
; | 461 .setValue(m_injectedScript.wrapObject(idbCursor->value(), String()))
; |
| 460 m_result->addItem(dataEntry); | 462 m_result->addItem(dataEntry); |
| 461 | 463 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 return; | 507 return; |
| 506 } | 508 } |
| 507 RefPtr<IDBObjectStore> idbObjectStore = objectStoreForTransaction(idbTra
nsaction.get(), m_objectStoreName); | 509 RefPtr<IDBObjectStore> idbObjectStore = objectStoreForTransaction(idbTra
nsaction.get(), m_objectStoreName); |
| 508 if (!idbObjectStore) { | 510 if (!idbObjectStore) { |
| 509 m_requestCallback->sendFailure("Could not get object store"); | 511 m_requestCallback->sendFailure("Could not get object store"); |
| 510 return; | 512 return; |
| 511 } | 513 } |
| 512 | 514 |
| 513 RefPtr<OpenCursorCallback> openCursorCallback = OpenCursorCallback::crea
te(m_injectedScript, m_requestCallback, m_skipCount, m_pageSize); | 515 RefPtr<OpenCursorCallback> openCursorCallback = OpenCursorCallback::crea
te(m_injectedScript, m_requestCallback, m_skipCount, m_pageSize); |
| 514 | 516 |
| 515 ExceptionCode ec = 0; | |
| 516 RefPtr<IDBRequest> idbRequest; | 517 RefPtr<IDBRequest> idbRequest; |
| 517 if (!m_indexName.isEmpty()) { | 518 if (!m_indexName.isEmpty()) { |
| 518 RefPtr<IDBIndex> idbIndex = indexForObjectStore(idbObjectStore.get()
, m_indexName); | 519 RefPtr<IDBIndex> idbIndex = indexForObjectStore(idbObjectStore.get()
, m_indexName); |
| 519 if (!idbIndex) { | 520 if (!idbIndex) { |
| 520 m_requestCallback->sendFailure("Could not get index"); | 521 m_requestCallback->sendFailure("Could not get index"); |
| 521 return; | 522 return; |
| 522 } | 523 } |
| 523 | 524 |
| 524 idbRequest = idbIndex->openCursor(context(), PassRefPtr<IDBKeyRange>
(m_idbKeyRange), IDBCursor::directionNext(), ec); | 525 idbRequest = idbIndex->openCursor(context(), PassRefPtr<IDBKeyRange>
(m_idbKeyRange), IDBCursor::directionNext(), IGNORE_EXCEPTION_STATE); |
| 525 } else | 526 } else { |
| 526 idbRequest = idbObjectStore->openCursor(context(), PassRefPtr<IDBKey
Range>(m_idbKeyRange), IDBCursor::directionNext(), ec); | 527 idbRequest = idbObjectStore->openCursor(context(), PassRefPtr<IDBKey
Range>(m_idbKeyRange), IDBCursor::directionNext(), IGNORE_EXCEPTION_STATE); |
| 528 } |
| 527 idbRequest->addEventListener(eventNames().successEvent, openCursorCallba
ck, false); | 529 idbRequest->addEventListener(eventNames().successEvent, openCursorCallba
ck, false); |
| 528 } | 530 } |
| 529 | 531 |
| 530 virtual RequestCallback* requestCallback() { return m_requestCallback.get();
} | 532 virtual RequestCallback* requestCallback() { return m_requestCallback.get();
} |
| 531 DataLoader(ScriptExecutionContext* scriptExecutionContext, PassRefPtr<Reques
tDataCallback> requestCallback, const InjectedScript& injectedScript, const Stri
ng& objectStoreName, const String& indexName, PassRefPtr<IDBKeyRange> idbKeyRang
e, int skipCount, unsigned pageSize) | 533 DataLoader(ScriptExecutionContext* scriptExecutionContext, PassRefPtr<Reques
tDataCallback> requestCallback, const InjectedScript& injectedScript, const Stri
ng& objectStoreName, const String& indexName, PassRefPtr<IDBKeyRange> idbKeyRang
e, int skipCount, unsigned pageSize) |
| 532 : ExecutableWithDatabase(scriptExecutionContext) | 534 : ExecutableWithDatabase(scriptExecutionContext) |
| 533 , m_requestCallback(requestCallback) | 535 , m_requestCallback(requestCallback) |
| 534 , m_injectedScript(injectedScript) | 536 , m_injectedScript(injectedScript) |
| 535 , m_objectStoreName(objectStoreName) | 537 , m_objectStoreName(objectStoreName) |
| 536 , m_indexName(indexName) | 538 , m_indexName(indexName) |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 IDBFactory* idbFactory = assertIDBFactory(errorString, document); | 618 IDBFactory* idbFactory = assertIDBFactory(errorString, document); |
| 617 if (!idbFactory) | 619 if (!idbFactory) |
| 618 return; | 620 return; |
| 619 | 621 |
| 620 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API | 622 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API |
| 621 v8::HandleScope handleScope; | 623 v8::HandleScope handleScope; |
| 622 v8::Handle<v8::Context> context = document->frame()->script()->mainWorldCont
ext(); | 624 v8::Handle<v8::Context> context = document->frame()->script()->mainWorldCont
ext(); |
| 623 ASSERT(!context.IsEmpty()); | 625 ASSERT(!context.IsEmpty()); |
| 624 v8::Context::Scope contextScope(context); | 626 v8::Context::Scope contextScope(context); |
| 625 | 627 |
| 626 ExceptionCode ec = 0; | 628 NonThrowExceptionState es; |
| 627 RefPtr<IDBRequest> idbRequest = idbFactory->getDatabaseNames(document, ec); | 629 RefPtr<IDBRequest> idbRequest = idbFactory->getDatabaseNames(document, es); |
| 628 if (ec) { | 630 if (es.hadException()) { |
| 629 requestCallback->sendFailure("Could not obtain database names."); | 631 requestCallback->sendFailure("Could not obtain database names."); |
| 630 return; | 632 return; |
| 631 } | 633 } |
| 632 idbRequest->addEventListener(eventNames().successEvent, GetDatabaseNamesCall
back::create(requestCallback, document->securityOrigin()->toRawString()), false)
; | 634 idbRequest->addEventListener(eventNames().successEvent, GetDatabaseNamesCall
back::create(requestCallback, document->securityOrigin()->toRawString()), false)
; |
| 633 } | 635 } |
| 634 | 636 |
| 635 void InspectorIndexedDBAgent::requestDatabase(ErrorString* errorString, const St
ring& securityOrigin, const String& databaseName, PassRefPtr<RequestDatabaseCall
back> requestCallback) | 637 void InspectorIndexedDBAgent::requestDatabase(ErrorString* errorString, const St
ring& securityOrigin, const String& databaseName, PassRefPtr<RequestDatabaseCall
back> requestCallback) |
| 636 { | 638 { |
| 637 Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin); | 639 Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin); |
| 638 Document* document = assertDocument(errorString, frame); | 640 Document* document = assertDocument(errorString, frame); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 if (!idbTransaction) { | 742 if (!idbTransaction) { |
| 741 m_requestCallback->sendFailure("Could not get transaction"); | 743 m_requestCallback->sendFailure("Could not get transaction"); |
| 742 return; | 744 return; |
| 743 } | 745 } |
| 744 RefPtr<IDBObjectStore> idbObjectStore = objectStoreForTransaction(idbTra
nsaction.get(), m_objectStoreName); | 746 RefPtr<IDBObjectStore> idbObjectStore = objectStoreForTransaction(idbTra
nsaction.get(), m_objectStoreName); |
| 745 if (!idbObjectStore) { | 747 if (!idbObjectStore) { |
| 746 m_requestCallback->sendFailure("Could not get object store"); | 748 m_requestCallback->sendFailure("Could not get object store"); |
| 747 return; | 749 return; |
| 748 } | 750 } |
| 749 | 751 |
| 750 ExceptionCode ec = 0; | 752 NonThrowExceptionState es; |
| 751 RefPtr<IDBRequest> idbRequest = idbObjectStore->clear(context(), ec); | 753 RefPtr<IDBRequest> idbRequest = idbObjectStore->clear(context(), es); |
| 752 ASSERT(!ec); | 754 ASSERT(!es.hadException()); |
| 753 if (ec) { | 755 if (es.hadException()) { |
| 756 ExceptionCode ec = es; |
| 754 m_requestCallback->sendFailure(String::format("Could not clear objec
t store '%s': %d", m_objectStoreName.utf8().data(), ec)); | 757 m_requestCallback->sendFailure(String::format("Could not clear objec
t store '%s': %d", m_objectStoreName.utf8().data(), ec)); |
| 755 return; | 758 return; |
| 756 } | 759 } |
| 757 idbTransaction->addEventListener(eventNames().completeEvent, ClearObject
StoreListener::create(m_requestCallback), false); | 760 idbTransaction->addEventListener(eventNames().completeEvent, ClearObject
StoreListener::create(m_requestCallback), false); |
| 758 } | 761 } |
| 759 | 762 |
| 760 virtual RequestCallback* requestCallback() { return m_requestCallback.get();
} | 763 virtual RequestCallback* requestCallback() { return m_requestCallback.get();
} |
| 761 private: | 764 private: |
| 762 const String m_objectStoreName; | 765 const String m_objectStoreName; |
| 763 RefPtr<ClearObjectStoreCallback> m_requestCallback; | 766 RefPtr<ClearObjectStoreCallback> m_requestCallback; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 777 v8::HandleScope handleScope; | 780 v8::HandleScope handleScope; |
| 778 v8::Handle<v8::Context> context = document->frame()->script()->mainWorldCont
ext(); | 781 v8::Handle<v8::Context> context = document->frame()->script()->mainWorldCont
ext(); |
| 779 ASSERT(!context.IsEmpty()); | 782 ASSERT(!context.IsEmpty()); |
| 780 v8::Context::Scope contextScope(context); | 783 v8::Context::Scope contextScope(context); |
| 781 | 784 |
| 782 RefPtr<ClearObjectStore> clearObjectStore = ClearObjectStore::create(documen
t, objectStoreName, requestCallback); | 785 RefPtr<ClearObjectStore> clearObjectStore = ClearObjectStore::create(documen
t, objectStoreName, requestCallback); |
| 783 clearObjectStore->start(idbFactory, document->securityOrigin(), databaseName
); | 786 clearObjectStore->start(idbFactory, document->securityOrigin(), databaseName
); |
| 784 } | 787 } |
| 785 | 788 |
| 786 } // namespace WebCore | 789 } // namespace WebCore |
| OLD | NEW |