Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/InspectorIndexedDBAgent.cpp

Issue 2796653003: Move ScriptState::forWorld/ScriptState::forMainWorld (Part 2) (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 15 matching lines...) Expand all
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 "modules/indexeddb/InspectorIndexedDBAgent.h" 31 #include "modules/indexeddb/InspectorIndexedDBAgent.h"
32 32
33 #include "bindings/core/v8/ExceptionState.h" 33 #include "bindings/core/v8/ExceptionState.h"
34 #include "bindings/core/v8/ScriptController.h" 34 #include "bindings/core/v8/ScriptController.h"
35 #include "bindings/core/v8/ScriptState.h" 35 #include "bindings/core/v8/ScriptState.h"
36 #include "bindings/core/v8/V8Binding.h"
36 #include "bindings/core/v8/V8PerIsolateData.h" 37 #include "bindings/core/v8/V8PerIsolateData.h"
37 #include "core/dom/DOMStringList.h" 38 #include "core/dom/DOMStringList.h"
38 #include "core/dom/Document.h" 39 #include "core/dom/Document.h"
39 #include "core/events/EventListener.h" 40 #include "core/events/EventListener.h"
40 #include "core/frame/LocalFrame.h" 41 #include "core/frame/LocalFrame.h"
41 #include "core/inspector/InspectedFrames.h" 42 #include "core/inspector/InspectedFrames.h"
42 #include "core/inspector/V8InspectorString.h" 43 #include "core/inspector/V8InspectorString.h"
43 #include "modules/IndexedDBNames.h" 44 #include "modules/IndexedDBNames.h"
44 #include "modules/indexeddb/GlobalIndexedDB.h" 45 #include "modules/indexeddb/GlobalIndexedDB.h"
45 #include "modules/indexeddb/IDBCursor.h" 46 #include "modules/indexeddb/IDBCursor.h"
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 requestCallback->sendFailure(Response::Error(kNoDocumentError)); 763 requestCallback->sendFailure(Response::Error(kNoDocumentError));
763 return; 764 return;
764 } 765 }
765 IDBFactory* idbFactory = nullptr; 766 IDBFactory* idbFactory = nullptr;
766 Response response = assertIDBFactory(document, idbFactory); 767 Response response = assertIDBFactory(document, idbFactory);
767 if (!response.isSuccess()) { 768 if (!response.isSuccess()) {
768 requestCallback->sendFailure(response); 769 requestCallback->sendFailure(response);
769 return; 770 return;
770 } 771 }
771 772
772 ScriptState* scriptState = ScriptState::forMainWorld(frame); 773 ScriptState* scriptState = toScriptStateForMainWorld(frame);
773 if (!scriptState) { 774 if (!scriptState) {
774 requestCallback->sendFailure(Response::InternalError()); 775 requestCallback->sendFailure(Response::InternalError());
775 return; 776 return;
776 } 777 }
777 ScriptState::Scope scope(scriptState); 778 ScriptState::Scope scope(scriptState);
778 DummyExceptionStateForTesting exceptionState; 779 DummyExceptionStateForTesting exceptionState;
779 IDBRequest* idbRequest = 780 IDBRequest* idbRequest =
780 idbFactory->getDatabaseNames(scriptState, exceptionState); 781 idbFactory->getDatabaseNames(scriptState, exceptionState);
781 if (exceptionState.hadException()) { 782 if (exceptionState.hadException()) {
782 requestCallback->sendFailure( 783 requestCallback->sendFailure(
(...skipping 19 matching lines...) Expand all
802 requestCallback->sendFailure(Response::Error(kNoDocumentError)); 803 requestCallback->sendFailure(Response::Error(kNoDocumentError));
803 return; 804 return;
804 } 805 }
805 IDBFactory* idbFactory = nullptr; 806 IDBFactory* idbFactory = nullptr;
806 Response response = assertIDBFactory(document, idbFactory); 807 Response response = assertIDBFactory(document, idbFactory);
807 if (!response.isSuccess()) { 808 if (!response.isSuccess()) {
808 requestCallback->sendFailure(response); 809 requestCallback->sendFailure(response);
809 return; 810 return;
810 } 811 }
811 812
812 ScriptState* scriptState = ScriptState::forMainWorld(frame); 813 ScriptState* scriptState = toScriptStateForMainWorld(frame);
813 if (!scriptState) { 814 if (!scriptState) {
814 requestCallback->sendFailure(Response::InternalError()); 815 requestCallback->sendFailure(Response::InternalError());
815 return; 816 return;
816 } 817 }
817 818
818 ScriptState::Scope scope(scriptState); 819 ScriptState::Scope scope(scriptState);
819 RefPtr<DatabaseLoader> databaseLoader = 820 RefPtr<DatabaseLoader> databaseLoader =
820 DatabaseLoader::create(scriptState, std::move(requestCallback)); 821 DatabaseLoader::create(scriptState, std::move(requestCallback));
821 databaseLoader->start(idbFactory, document->getSecurityOrigin(), 822 databaseLoader->start(idbFactory, document->getSecurityOrigin(),
822 databaseName); 823 databaseName);
(...skipping 23 matching lines...) Expand all
846 } 847 }
847 848
848 IDBKeyRange* idbKeyRange = keyRange.isJust() 849 IDBKeyRange* idbKeyRange = keyRange.isJust()
849 ? idbKeyRangeFromKeyRange(keyRange.fromJust()) 850 ? idbKeyRangeFromKeyRange(keyRange.fromJust())
850 : nullptr; 851 : nullptr;
851 if (keyRange.isJust() && !idbKeyRange) { 852 if (keyRange.isJust() && !idbKeyRange) {
852 requestCallback->sendFailure(Response::Error("Can not parse key range.")); 853 requestCallback->sendFailure(Response::Error("Can not parse key range."));
853 return; 854 return;
854 } 855 }
855 856
856 ScriptState* scriptState = ScriptState::forMainWorld(frame); 857 ScriptState* scriptState = toScriptStateForMainWorld(frame);
857 if (!scriptState) { 858 if (!scriptState) {
858 requestCallback->sendFailure(Response::InternalError()); 859 requestCallback->sendFailure(Response::InternalError());
859 return; 860 return;
860 } 861 }
861 862
862 ScriptState::Scope scope(scriptState); 863 ScriptState::Scope scope(scriptState);
863 RefPtr<DataLoader> dataLoader = DataLoader::create( 864 RefPtr<DataLoader> dataLoader = DataLoader::create(
864 m_v8Session, scriptState, std::move(requestCallback), objectStoreName, 865 m_v8Session, scriptState, std::move(requestCallback), objectStoreName,
865 indexName, idbKeyRange, skipCount, pageSize); 866 indexName, idbKeyRange, skipCount, pageSize);
866 dataLoader->start(idbFactory, document->getSecurityOrigin(), databaseName); 867 dataLoader->start(idbFactory, document->getSecurityOrigin(), databaseName);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 requestCallback->sendFailure(Response::Error(kNoDocumentError)); 973 requestCallback->sendFailure(Response::Error(kNoDocumentError));
973 return; 974 return;
974 } 975 }
975 IDBFactory* idbFactory = nullptr; 976 IDBFactory* idbFactory = nullptr;
976 Response response = assertIDBFactory(document, idbFactory); 977 Response response = assertIDBFactory(document, idbFactory);
977 if (!response.isSuccess()) { 978 if (!response.isSuccess()) {
978 requestCallback->sendFailure(response); 979 requestCallback->sendFailure(response);
979 return; 980 return;
980 } 981 }
981 982
982 ScriptState* scriptState = ScriptState::forMainWorld(frame); 983 ScriptState* scriptState = toScriptStateForMainWorld(frame);
983 if (!scriptState) { 984 if (!scriptState) {
984 requestCallback->sendFailure(Response::InternalError()); 985 requestCallback->sendFailure(Response::InternalError());
985 return; 986 return;
986 } 987 }
987 988
988 ScriptState::Scope scope(scriptState); 989 ScriptState::Scope scope(scriptState);
989 RefPtr<ClearObjectStore> clearObjectStore = ClearObjectStore::create( 990 RefPtr<ClearObjectStore> clearObjectStore = ClearObjectStore::create(
990 scriptState, objectStoreName, std::move(requestCallback)); 991 scriptState, objectStoreName, std::move(requestCallback));
991 clearObjectStore->start(idbFactory, document->getSecurityOrigin(), 992 clearObjectStore->start(idbFactory, document->getSecurityOrigin(),
992 databaseName); 993 databaseName);
(...skipping 10 matching lines...) Expand all
1003 requestCallback->sendFailure(Response::Error(kNoDocumentError)); 1004 requestCallback->sendFailure(Response::Error(kNoDocumentError));
1004 return; 1005 return;
1005 } 1006 }
1006 IDBFactory* idbFactory = nullptr; 1007 IDBFactory* idbFactory = nullptr;
1007 Response response = assertIDBFactory(document, idbFactory); 1008 Response response = assertIDBFactory(document, idbFactory);
1008 if (!response.isSuccess()) { 1009 if (!response.isSuccess()) {
1009 requestCallback->sendFailure(response); 1010 requestCallback->sendFailure(response);
1010 return; 1011 return;
1011 } 1012 }
1012 1013
1013 ScriptState* scriptState = ScriptState::forMainWorld(frame); 1014 ScriptState* scriptState = toScriptStateForMainWorld(frame);
1014 if (!scriptState) { 1015 if (!scriptState) {
1015 requestCallback->sendFailure(Response::InternalError()); 1016 requestCallback->sendFailure(Response::InternalError());
1016 return; 1017 return;
1017 } 1018 }
1018 ScriptState::Scope scope(scriptState); 1019 ScriptState::Scope scope(scriptState);
1019 DummyExceptionStateForTesting exceptionState; 1020 DummyExceptionStateForTesting exceptionState;
1020 IDBRequest* idbRequest = idbFactory->closeConnectionsAndDeleteDatabase( 1021 IDBRequest* idbRequest = idbFactory->closeConnectionsAndDeleteDatabase(
1021 scriptState, databaseName, exceptionState); 1022 scriptState, databaseName, exceptionState);
1022 if (exceptionState.hadException()) { 1023 if (exceptionState.hadException()) {
1023 requestCallback->sendFailure(Response::Error("Could not delete database.")); 1024 requestCallback->sendFailure(Response::Error("Could not delete database."));
1024 return; 1025 return;
1025 } 1026 }
1026 idbRequest->addEventListener( 1027 idbRequest->addEventListener(
1027 EventTypeNames::success, 1028 EventTypeNames::success,
1028 DeleteCallback::create(std::move(requestCallback), 1029 DeleteCallback::create(std::move(requestCallback),
1029 document->getSecurityOrigin()->toRawString()), 1030 document->getSecurityOrigin()->toRawString()),
1030 false); 1031 false);
1031 } 1032 }
1032 1033
1033 DEFINE_TRACE(InspectorIndexedDBAgent) { 1034 DEFINE_TRACE(InspectorIndexedDBAgent) {
1034 visitor->trace(m_inspectedFrames); 1035 visitor->trace(m_inspectedFrames);
1035 InspectorBaseAgent::trace(visitor); 1036 InspectorBaseAgent::trace(visitor);
1036 } 1037 }
1037 1038
1038 } // namespace blink 1039 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698