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

Side by Side Diff: Source/bindings/core/dart/DartNativeUtilities.cpp

Issue 2543703003: Added setting up VMLibraryHooks for Dartium to support resolvePageUri (Closed)
Patch Set: Incorporated Siva suggestion Created 3 years, 11 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
« no previous file with comments | « Source/bindings/core/dart/DartNativeUtilities.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012, Google Inc. 1 // Copyright 2012, 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // TODO(vsm): Return isolate future. 148 // TODO(vsm): Return isolate future.
149 dartController->spawnDomUri(uri); 149 dartController->spawnDomUri(uri);
150 return; 150 return;
151 } 151 }
152 152
153 fail: 153 fail:
154 Dart_ThrowException(exception); 154 Dart_ThrowException(exception);
155 ASSERT_NOT_REACHED(); 155 ASSERT_NOT_REACHED();
156 } 156 }
157 157
158 void resolveUri(Dart_NativeArguments args)
159 {
160 Dart_Handle exception = 0;
161 {
162 DartDOMData* domData = static_cast<DartDOMData*>(Dart_GetNativeIsolateDa ta(args));
163 RefPtr<blink::DartApplicationLoader> loader = domData->applicationLoader ();
164
165 Dart_Handle uriArg = Dart_GetNativeArgument(args, 0);
166 Dart_Handle uriAsString = Dart_Invoke(uriArg, Dart_NewStringFromCString( "toString"), 0, NULL);
167 DartStringAdapter uri = DartUtilities::dartToString(uriAsString, excepti on);
168 if (exception)
169 goto fail;
170 String uriString = (String)uri;
171
172 String resolvedUrl = DartApplicationLoader::resolveUrl(loader->scriptUrl (), uriString, loader->packageRoot());
173
174 Dart_Handle constructorArg = DartUtilities::stringToDartString(resolvedU rl);
175
176 // Call the Uri.File constructor to create a Uri from the uri string ret urned from DartApplicationLoader's
177 // resolveUrl.
178 Dart_Handle coreLib = Dart_LookupLibrary(Dart_NewStringFromCString("dart :core"));
179 Dart_Handle uriClass = Dart_GetType(coreLib, Dart_NewStringFromCString(" Uri"), 0, 0);
180 Dart_Handle ret = Dart_New(uriClass, Dart_NewStringFromCString("file"), 1, &constructorArg);
181
182 Dart_SetReturnValue(args, ret);
183
184 return;
185 }
186
187 fail:
188 Dart_ThrowException(exception);
189 ASSERT_NOT_REACHED();
190 }
191
158 class SpawnDomFunctionTask : public ExecutionContextTask { 192 class SpawnDomFunctionTask : public ExecutionContextTask {
159 public: 193 public:
160 SpawnDomFunctionTask(const char* libraryUrl, const char* functionName, Dart_ Port replyTo, DartDOMData* parentDOMData) 194 SpawnDomFunctionTask(const char* libraryUrl, const char* functionName, Dart_ Port replyTo, DartDOMData* parentDOMData)
161 : m_libraryUrl(strdup(libraryUrl)) 195 : m_libraryUrl(strdup(libraryUrl))
162 , m_functionName(strdup(functionName)) 196 , m_functionName(strdup(functionName))
163 , m_replyTo(replyTo) 197 , m_replyTo(replyTo)
164 , m_parentDOMData(parentDOMData) { } 198 , m_parentDOMData(parentDOMData) { }
165 199
166 ~SpawnDomFunctionTask() 200 ~SpawnDomFunctionTask()
167 { 201 {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 288
255 } // namespace DartNativeUtilitiesInternal 289 } // namespace DartNativeUtilitiesInternal
256 290
257 extern Dart_NativeFunction blinkSnapshotResolver(Dart_Handle name, int argumentC ount, bool* autoSetupScope); 291 extern Dart_NativeFunction blinkSnapshotResolver(Dart_Handle name, int argumentC ount, bool* autoSetupScope);
258 extern Dart_NativeFunction customDartDOMStringMapResolver(Dart_Handle name, int argumentCount, bool* autoSetupScope); 292 extern Dart_NativeFunction customDartDOMStringMapResolver(Dart_Handle name, int argumentCount, bool* autoSetupScope);
259 293
260 static DartNativeEntry nativeEntries[] = { 294 static DartNativeEntry nativeEntries[] = {
261 { DartNativeUtilitiesInternal::forwardingPrint, 1, "Utils_forwardingPrint" } , 295 { DartNativeUtilitiesInternal::forwardingPrint, 1, "Utils_forwardingPrint" } ,
262 { DartNativeUtilitiesInternal::getNewIsolateId, 0, "Utils_getNewIsolateId" } , 296 { DartNativeUtilitiesInternal::getNewIsolateId, 0, "Utils_getNewIsolateId" } ,
263 { DartNativeUtilitiesInternal::spawnDomUri, 1, "Utils_spawnDomUri" }, 297 { DartNativeUtilitiesInternal::spawnDomUri, 1, "Utils_spawnDomUri" },
298 { DartNativeUtilitiesInternal::resolveUri, 1, "Utils_resolvePackageUri" },
264 { 0, 0, 0 }, 299 { 0, 0, 0 },
265 }; 300 };
266 301
267 Dart_NativeFunction commonHtmlResolver(Dart_Handle name, int argumentCount, bool * autoSetupScope) 302 Dart_NativeFunction commonHtmlResolver(Dart_Handle name, int argumentCount, bool * autoSetupScope)
268 { 303 {
269 String str = DartUtilities::toString(name); 304 String str = DartUtilities::toString(name);
270 if (argumentCount == 2 && str == "Utils_spawnDomHelper") 305 if (argumentCount == 2 && str == "Utils_spawnDomHelper")
271 return DartNativeUtilitiesInternal::spawnDomHelper; 306 return DartNativeUtilitiesInternal::spawnDomHelper;
272 return 0; 307 return 0;
273 } 308 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 if (nf == nativeEntries[i].nativeFunction) { 346 if (nf == nativeEntries[i].nativeFunction) {
312 return reinterpret_cast<const uint8_t*>(nativeEntries[i].name); 347 return reinterpret_cast<const uint8_t*>(nativeEntries[i].name);
313 } 348 }
314 } 349 }
315 350
316 return 0; 351 return 0;
317 } 352 }
318 353
319 354
320 } 355 }
OLDNEW
« no previous file with comments | « Source/bindings/core/dart/DartNativeUtilities.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698