| 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 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 return nullptr; | 623 return nullptr; |
| 624 } | 624 } |
| 625 IDBFactory* idbFactory = GlobalIndexedDB::indexedDB(*domWindow); | 625 IDBFactory* idbFactory = GlobalIndexedDB::indexedDB(*domWindow); |
| 626 | 626 |
| 627 if (!idbFactory) | 627 if (!idbFactory) |
| 628 *errorString = "No IndexedDB factory for given frame found"; | 628 *errorString = "No IndexedDB factory for given frame found"; |
| 629 | 629 |
| 630 return idbFactory; | 630 return idbFactory; |
| 631 } | 631 } |
| 632 | 632 |
| 633 void InspectorIndexedDBAgent::requestDatabaseNames(ErrorString* errorString, con
st String& securityOrigin, std::unique_ptr<RequestDatabaseNamesCallback> request
Callback) | 633 void InspectorIndexedDBAgent::requestDatabaseNames(const String& securityOrigin,
std::unique_ptr<RequestDatabaseNamesCallback> requestCallback) |
| 634 { | 634 { |
| 635 LocalFrame* frame = m_inspectedFrames->frameWithSecurityOrigin(securityOrigi
n); | 635 LocalFrame* frame = m_inspectedFrames->frameWithSecurityOrigin(securityOrigi
n); |
| 636 Document* document = assertDocument(errorString, frame); | 636 ErrorString errorString; |
| 637 if (!document) | 637 Document* document = assertDocument(&errorString, frame); |
| 638 if (!document) { |
| 639 requestCallback->sendFailure(errorString); |
| 638 return; | 640 return; |
| 639 IDBFactory* idbFactory = assertIDBFactory(errorString, document); | 641 } |
| 640 if (!idbFactory) | 642 IDBFactory* idbFactory = assertIDBFactory(&errorString, document); |
| 643 if (!idbFactory) { |
| 644 requestCallback->sendFailure(errorString); |
| 641 return; | 645 return; |
| 646 } |
| 642 | 647 |
| 643 ScriptState* scriptState = ScriptState::forMainWorld(frame); | 648 ScriptState* scriptState = ScriptState::forMainWorld(frame); |
| 644 if (!scriptState) | 649 if (!scriptState) |
| 645 return; | 650 return; |
| 646 ScriptState::Scope scope(scriptState); | 651 ScriptState::Scope scope(scriptState); |
| 647 TrackExceptionState exceptionState; | 652 TrackExceptionState exceptionState; |
| 648 IDBRequest* idbRequest = idbFactory->getDatabaseNames(scriptState, exception
State); | 653 IDBRequest* idbRequest = idbFactory->getDatabaseNames(scriptState, exception
State); |
| 649 if (exceptionState.hadException()) { | 654 if (exceptionState.hadException()) { |
| 650 requestCallback->sendFailure("Could not obtain database names."); | 655 requestCallback->sendFailure("Could not obtain database names."); |
| 651 return; | 656 return; |
| 652 } | 657 } |
| 653 idbRequest->addEventListener(EventTypeNames::success, GetDatabaseNamesCallba
ck::create(std::move(requestCallback), document->getSecurityOrigin()->toRawStrin
g()), false); | 658 idbRequest->addEventListener(EventTypeNames::success, GetDatabaseNamesCallba
ck::create(std::move(requestCallback), document->getSecurityOrigin()->toRawStrin
g()), false); |
| 654 } | 659 } |
| 655 | 660 |
| 656 void InspectorIndexedDBAgent::requestDatabase(ErrorString* errorString, const St
ring& securityOrigin, const String& databaseName, std::unique_ptr<RequestDatabas
eCallback> requestCallback) | 661 void InspectorIndexedDBAgent::requestDatabase(const String& securityOrigin, cons
t String& databaseName, std::unique_ptr<RequestDatabaseCallback> requestCallback
) |
| 657 { | 662 { |
| 658 LocalFrame* frame = m_inspectedFrames->frameWithSecurityOrigin(securityOrigi
n); | 663 LocalFrame* frame = m_inspectedFrames->frameWithSecurityOrigin(securityOrigi
n); |
| 659 Document* document = assertDocument(errorString, frame); | 664 ErrorString errorString; |
| 660 if (!document) | 665 Document* document = assertDocument(&errorString, frame); |
| 666 if (!document) { |
| 667 requestCallback->sendFailure(errorString); |
| 661 return; | 668 return; |
| 662 IDBFactory* idbFactory = assertIDBFactory(errorString, document); | 669 } |
| 663 if (!idbFactory) | 670 IDBFactory* idbFactory = assertIDBFactory(&errorString, document); |
| 671 if (!idbFactory) { |
| 672 requestCallback->sendFailure(errorString); |
| 664 return; | 673 return; |
| 674 } |
| 665 | 675 |
| 666 ScriptState* scriptState = ScriptState::forMainWorld(frame); | 676 ScriptState* scriptState = ScriptState::forMainWorld(frame); |
| 667 if (!scriptState) | 677 if (!scriptState) |
| 668 return; | 678 return; |
| 669 ScriptState::Scope scope(scriptState); | 679 ScriptState::Scope scope(scriptState); |
| 670 RefPtr<DatabaseLoader> databaseLoader = DatabaseLoader::create(scriptState,
std::move(requestCallback)); | 680 RefPtr<DatabaseLoader> databaseLoader = DatabaseLoader::create(scriptState,
std::move(requestCallback)); |
| 671 databaseLoader->start(idbFactory, document->getSecurityOrigin(), databaseNam
e); | 681 databaseLoader->start(idbFactory, document->getSecurityOrigin(), databaseNam
e); |
| 672 } | 682 } |
| 673 | 683 |
| 674 void InspectorIndexedDBAgent::requestData(ErrorString* errorString, | 684 void InspectorIndexedDBAgent::requestData( |
| 675 const String& securityOrigin, | 685 const String& securityOrigin, |
| 676 const String& databaseName, | 686 const String& databaseName, |
| 677 const String& objectStoreName, | 687 const String& objectStoreName, |
| 678 const String& indexName, | 688 const String& indexName, |
| 679 int skipCount, | 689 int skipCount, |
| 680 int pageSize, | 690 int pageSize, |
| 681 const Maybe<protocol::IndexedDB::KeyRange>& keyRange, | 691 const Maybe<protocol::IndexedDB::KeyRange>& keyRange, |
| 682 std::unique_ptr<RequestDataCallback> requestCallback) | 692 std::unique_ptr<RequestDataCallback> requestCallback) |
| 683 { | 693 { |
| 684 LocalFrame* frame = m_inspectedFrames->frameWithSecurityOrigin(securityOrigi
n); | 694 LocalFrame* frame = m_inspectedFrames->frameWithSecurityOrigin(securityOrigi
n); |
| 685 Document* document = assertDocument(errorString, frame); | 695 ErrorString errorString; |
| 686 if (!document) | 696 Document* document = assertDocument(&errorString, frame); |
| 697 if (!document) { |
| 698 requestCallback->sendFailure(errorString); |
| 687 return; | 699 return; |
| 688 IDBFactory* idbFactory = assertIDBFactory(errorString, document); | 700 } |
| 689 if (!idbFactory) | 701 IDBFactory* idbFactory = assertIDBFactory(&errorString, document); |
| 702 if (!idbFactory) { |
| 703 requestCallback->sendFailure(errorString); |
| 690 return; | 704 return; |
| 705 } |
| 691 | 706 |
| 692 IDBKeyRange* idbKeyRange = keyRange.isJust() ? idbKeyRangeFromKeyRange(keyRa
nge.fromJust()) : nullptr; | 707 IDBKeyRange* idbKeyRange = keyRange.isJust() ? idbKeyRangeFromKeyRange(keyRa
nge.fromJust()) : nullptr; |
| 693 if (keyRange.isJust() && !idbKeyRange) { | 708 if (keyRange.isJust() && !idbKeyRange) { |
| 694 *errorString = "Can not parse key range."; | 709 requestCallback->sendFailure("Can not parse key range."); |
| 695 return; | 710 return; |
| 696 } | 711 } |
| 697 | 712 |
| 698 ScriptState* scriptState = ScriptState::forMainWorld(frame); | 713 ScriptState* scriptState = ScriptState::forMainWorld(frame); |
| 699 if (!scriptState) | 714 if (!scriptState) |
| 700 return; | 715 return; |
| 701 ScriptState::Scope scope(scriptState); | 716 ScriptState::Scope scope(scriptState); |
| 702 RefPtr<DataLoader> dataLoader = DataLoader::create(m_v8Session, scriptState,
std::move(requestCallback), objectStoreName, indexName, idbKeyRange, skipCount,
pageSize); | 717 RefPtr<DataLoader> dataLoader = DataLoader::create(m_v8Session, scriptState,
std::move(requestCallback), objectStoreName, indexName, idbKeyRange, skipCount,
pageSize); |
| 703 dataLoader->start(idbFactory, document->getSecurityOrigin(), databaseName); | 718 dataLoader->start(idbFactory, document->getSecurityOrigin(), databaseName); |
| 704 } | 719 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 } | 796 } |
| 782 idbTransaction->addEventListener(EventTypeNames::complete, ClearObjectSt
oreListener::create(std::move(m_requestCallback)), false); | 797 idbTransaction->addEventListener(EventTypeNames::complete, ClearObjectSt
oreListener::create(std::move(m_requestCallback)), false); |
| 783 } | 798 } |
| 784 | 799 |
| 785 RequestCallback* getRequestCallback() override { return m_requestCallback.ge
t(); } | 800 RequestCallback* getRequestCallback() override { return m_requestCallback.ge
t(); } |
| 786 private: | 801 private: |
| 787 const String m_objectStoreName; | 802 const String m_objectStoreName; |
| 788 std::unique_ptr<ClearObjectStoreCallback> m_requestCallback; | 803 std::unique_ptr<ClearObjectStoreCallback> m_requestCallback; |
| 789 }; | 804 }; |
| 790 | 805 |
| 791 void InspectorIndexedDBAgent::clearObjectStore(ErrorString* errorString, const S
tring& securityOrigin, const String& databaseName, const String& objectStoreName
, std::unique_ptr<ClearObjectStoreCallback> requestCallback) | 806 void InspectorIndexedDBAgent::clearObjectStore(const String& securityOrigin, con
st String& databaseName, const String& objectStoreName, std::unique_ptr<ClearObj
ectStoreCallback> requestCallback) |
| 792 { | 807 { |
| 793 LocalFrame* frame = m_inspectedFrames->frameWithSecurityOrigin(securityOrigi
n); | 808 LocalFrame* frame = m_inspectedFrames->frameWithSecurityOrigin(securityOrigi
n); |
| 794 Document* document = assertDocument(errorString, frame); | 809 ErrorString errorString; |
| 795 if (!document) | 810 Document* document = assertDocument(&errorString, frame); |
| 811 if (!document) { |
| 812 requestCallback->sendFailure(errorString); |
| 796 return; | 813 return; |
| 797 IDBFactory* idbFactory = assertIDBFactory(errorString, document); | 814 } |
| 798 if (!idbFactory) | 815 IDBFactory* idbFactory = assertIDBFactory(&errorString, document); |
| 816 if (!idbFactory) { |
| 817 requestCallback->sendFailure(errorString); |
| 799 return; | 818 return; |
| 819 } |
| 800 | 820 |
| 801 ScriptState* scriptState = ScriptState::forMainWorld(frame); | 821 ScriptState* scriptState = ScriptState::forMainWorld(frame); |
| 802 if (!scriptState) | 822 if (!scriptState) |
| 803 return; | 823 return; |
| 804 ScriptState::Scope scope(scriptState); | 824 ScriptState::Scope scope(scriptState); |
| 805 RefPtr<ClearObjectStore> clearObjectStore = ClearObjectStore::create(scriptS
tate, objectStoreName, std::move(requestCallback)); | 825 RefPtr<ClearObjectStore> clearObjectStore = ClearObjectStore::create(scriptS
tate, objectStoreName, std::move(requestCallback)); |
| 806 clearObjectStore->start(idbFactory, document->getSecurityOrigin(), databaseN
ame); | 826 clearObjectStore->start(idbFactory, document->getSecurityOrigin(), databaseN
ame); |
| 807 } | 827 } |
| 808 | 828 |
| 809 DEFINE_TRACE(InspectorIndexedDBAgent) | 829 DEFINE_TRACE(InspectorIndexedDBAgent) |
| 810 { | 830 { |
| 811 visitor->trace(m_inspectedFrames); | 831 visitor->trace(m_inspectedFrames); |
| 812 InspectorBaseAgent::trace(visitor); | 832 InspectorBaseAgent::trace(visitor); |
| 813 } | 833 } |
| 814 | 834 |
| 815 } // namespace blink | 835 } // namespace blink |
| OLD | NEW |