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

Side by Side Diff: Source/bindings/dart/DartController.cpp

Issue 33973002: Fix for https://code.google.com/p/dart/issues/detail?id=5851 Proper line #s and columns for Dart er… (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: ready to review Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009, Google Inc. 1 // Copyright (c) 2009, Google Inc.
2 // All rights reserved. 2 // 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // navigation. 193 // navigation.
194 Dart_Handle localHandle = DartDocument::toDart(document); 194 Dart_Handle localHandle = DartDocument::toDart(document);
195 Dart_PersistentHandle strongHandle = Dart_NewPersistentHandle(localHandl e); 195 Dart_PersistentHandle strongHandle = Dart_NewPersistentHandle(localHandl e);
196 // We need a weak handle to always reachable object to temporary render 196 // We need a weak handle to always reachable object to temporary render
197 // so weak handles strong, see the corresponding logic in 197 // so weak handles strong, see the corresponding logic in
198 // DartGCController. 198 // DartGCController.
199 domData->setReachableWeakHandle(Dart_NewWeakPersistentHandle(localHandle , 0, 0)); 199 domData->setReachableWeakHandle(Dart_NewWeakPersistentHandle(localHandle , 0, 0));
200 200
201 DartDebugServer::shared().registerIsolate(isolate); 201 DartDebugServer::shared().registerIsolate(isolate);
202 } 202 }
203
203 return isolate; 204 return isolate;
204 } 205 }
205 206
206 void DartController::createDOMEnabledIsolateIfNeeded(const String& scriptURL, co nst String& entryPoint, Document* document) 207 void DartController::createDOMEnabledIsolateIfNeeded(const String& scriptURL, co nst String& entryPoint, Document* document)
207 { 208 {
208 if (m_isolate) { 209 if (m_isolate) {
209 Dart_EnterIsolate(m_isolate); 210 Dart_EnterIsolate(m_isolate);
210 return; 211 return;
211 } 212 }
212 // FIXME: proper error reporting. 213 // FIXME: proper error reporting.
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 { 876 {
876 if (!m_isolate) 877 if (!m_isolate)
877 return; 878 return;
878 879
879 v8::HandleScope handleScope; 880 v8::HandleScope handleScope;
880 v8::Handle<v8::Context> v8Context = v8ScriptState->context(); 881 v8::Handle<v8::Context> v8Context = v8ScriptState->context();
881 882
882 collectScriptStatesForIsolate(m_isolate, v8Context, result); 883 collectScriptStatesForIsolate(m_isolate, v8Context, result);
883 } 884 }
884 885
886 LibraryIdMap* DartController::libraryIdMapForIsolate(Dart_Isolate isolate)
887 {
888 LibraryIdMap* libraryIdMap;
889 ScriptStatesMap::iterator it = m_scriptStates.find(isolate);
890 if (it == m_scriptStates.end()) {
891 libraryIdMap = new LibraryIdMap();
892 m_scriptStates.set(isolate, libraryIdMap);
893 } else {
894 libraryIdMap = it->value;
895 }
896 return libraryIdMap;
897 }
898
899 DartScriptState* DartController::lookupScriptState(Dart_Isolate isolate, v8::Han dle<v8::Context> v8Context, intptr_t libraryId)
900 {
901 return lookupScriptStateFromLibraryIdMap(isolate, v8Context, libraryIdMapFor Isolate(isolate), libraryId);
902 }
903
904 DartScriptState* DartController::lookupScriptStateFromLibraryIdMap(Dart_Isolate isolate, v8::Handle<v8::Context> v8Context, LibraryIdMap* libraryIdMap, intptr_t libraryId)
905 {
906 // -1 cannot be used as a HashMap key however library ids are
907 // guaranteed to be non-negative so it is a non-issue.
908 ASSERT(libraryId >= 0);
909 // 0 cannot be used as a HashMap key so we add 1 to the library id to
910 // create a valid key.
911 intptr_t libraryIdKey = libraryId + 1;
912 LibraryIdMap::iterator libraryIter = libraryIdMap->find(libraryIdKey);
913 DartScriptState* scriptState;
914 if (libraryIter == libraryIdMap->end()) {
915 scriptState = new DartScriptState(isolate, libraryId, v8Context);
916 libraryIdMap->set(libraryIdKey, scriptState);
917 } else {
918 scriptState = libraryIter->value;
919 ASSERT(scriptState);
920 }
921 return scriptState;
922 }
923
885 void DartController::collectScriptStatesForIsolate(Dart_Isolate isolate, v8::Han dle<v8::Context> v8Context, Vector<ScriptState*>& result) 924 void DartController::collectScriptStatesForIsolate(Dart_Isolate isolate, v8::Han dle<v8::Context> v8Context, Vector<ScriptState*>& result)
886 { 925 {
887 if (!isolate) 926 if (!isolate)
888 return; 927 return;
889 DartIsolateScope scope(isolate); 928 DartIsolateScope scope(isolate);
890 DartApiScope apiScope; 929 DartApiScope apiScope;
891 ScriptStatesMap::iterator it = m_scriptStates.find(isolate); 930 LibraryIdMap* libraryIdMap = libraryIdMapForIsolate(isolate);
892 LibraryIdMap* libraryIdMap;
893 if (it == m_scriptStates.end()) {
894 libraryIdMap = new LibraryIdMap();
895 m_scriptStates.set(isolate, libraryIdMap);
896 } else {
897 libraryIdMap = it->value;
898 }
899 Dart_Handle libraryIdList = Dart_GetLibraryIds(); 931 Dart_Handle libraryIdList = Dart_GetLibraryIds();
900 932
901 intptr_t length = 0; 933 intptr_t length = 0;
902 Dart_Handle res = Dart_ListLength(libraryIdList, &length); 934 Dart_Handle res = Dart_ListLength(libraryIdList, &length);
903 935
904 for (intptr_t i = 0; i < length; i++) { 936 for (intptr_t i = 0; i < length; i++) {
905 Dart_Handle libraryIdHandle = Dart_ListGetAt(libraryIdList, i); 937 Dart_Handle libraryIdHandle = Dart_ListGetAt(libraryIdList, i);
906 Dart_Handle exception = 0; 938 Dart_Handle exception = 0;
907 intptr_t libraryId = DartUtilities::toInteger(libraryIdHandle, exception ); 939 intptr_t libraryId = DartUtilities::toInteger(libraryIdHandle, exception );
908 ASSERT(!exception); 940 ASSERT(!exception);
909 // -1 cannot be used as a HashMap key however library ids are 941 DartScriptState* scriptState = lookupScriptStateFromLibraryIdMap(isolate , v8Context, libraryIdMap, libraryId);
910 // guaranteed to be non-negative so it is a non-issue.
911 ASSERT(libraryId >= 0);
912 // 0 cannot be used as a HashMap key so we add 1 to the library id to
913 // create a valid key.
914 intptr_t libraryIdKey = libraryId + 1;
915 LibraryIdMap::iterator libraryIter = libraryIdMap->find(libraryIdKey);
916 DartScriptState* scriptState;
917 if (libraryIter == libraryIdMap->end()) {
918 scriptState = new DartScriptState(isolate, libraryId, v8Context);
919 libraryIdMap->set(libraryIdKey, scriptState);
920 } else {
921 scriptState = libraryIter->value;
922 ASSERT(scriptState);
923 }
924 result.append(scriptState); 942 result.append(scriptState);
925 } 943 }
926 } 944 }
927 945
928 } 946 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698