| OLD | NEW |
| 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 Loading... |
| 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 DartStringAdapter uri = DartUtilities::dartToString(args, 0, exception); |
| 166 if (exception) |
| 167 goto fail; |
| 168 String uriString = (String)uri; |
| 169 |
| 170 String resolvedUrl = DartApplicationLoader::resolveUrl(loader->scriptUrl
(), uriString, loader->packageRoot()); |
| 171 |
| 172 Dart_Handle constructorArg = DartUtilities::stringToDartString(resolvedU
rl); |
| 173 |
| 174 Dart_Handle coreLib = Dart_LookupLibrary(Dart_NewStringFromCString("dart
:core")); |
| 175 Dart_Handle uriClass = Dart_GetType(coreLib, Dart_NewStringFromCString("
Uri"), 0, 0); |
| 176 Dart_Handle ret = Dart_New(uriClass, Dart_NewStringFromCString("file"),
1, &constructorArg); |
| 177 |
| 178 Dart_SetReturnValue(args, ret); |
| 179 |
| 180 return; |
| 181 } |
| 182 |
| 183 fail: |
| 184 Dart_ThrowException(exception); |
| 185 ASSERT_NOT_REACHED(); |
| 186 } |
| 187 |
| 158 class SpawnDomFunctionTask : public ExecutionContextTask { | 188 class SpawnDomFunctionTask : public ExecutionContextTask { |
| 159 public: | 189 public: |
| 160 SpawnDomFunctionTask(const char* libraryUrl, const char* functionName, Dart_
Port replyTo, DartDOMData* parentDOMData) | 190 SpawnDomFunctionTask(const char* libraryUrl, const char* functionName, Dart_
Port replyTo, DartDOMData* parentDOMData) |
| 161 : m_libraryUrl(strdup(libraryUrl)) | 191 : m_libraryUrl(strdup(libraryUrl)) |
| 162 , m_functionName(strdup(functionName)) | 192 , m_functionName(strdup(functionName)) |
| 163 , m_replyTo(replyTo) | 193 , m_replyTo(replyTo) |
| 164 , m_parentDOMData(parentDOMData) { } | 194 , m_parentDOMData(parentDOMData) { } |
| 165 | 195 |
| 166 ~SpawnDomFunctionTask() | 196 ~SpawnDomFunctionTask() |
| 167 { | 197 { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 284 |
| 255 } // namespace DartNativeUtilitiesInternal | 285 } // namespace DartNativeUtilitiesInternal |
| 256 | 286 |
| 257 extern Dart_NativeFunction blinkSnapshotResolver(Dart_Handle name, int argumentC
ount, bool* autoSetupScope); | 287 extern Dart_NativeFunction blinkSnapshotResolver(Dart_Handle name, int argumentC
ount, bool* autoSetupScope); |
| 258 extern Dart_NativeFunction customDartDOMStringMapResolver(Dart_Handle name, int
argumentCount, bool* autoSetupScope); | 288 extern Dart_NativeFunction customDartDOMStringMapResolver(Dart_Handle name, int
argumentCount, bool* autoSetupScope); |
| 259 | 289 |
| 260 static DartNativeEntry nativeEntries[] = { | 290 static DartNativeEntry nativeEntries[] = { |
| 261 { DartNativeUtilitiesInternal::forwardingPrint, 1, "Utils_forwardingPrint" }
, | 291 { DartNativeUtilitiesInternal::forwardingPrint, 1, "Utils_forwardingPrint" }
, |
| 262 { DartNativeUtilitiesInternal::getNewIsolateId, 0, "Utils_getNewIsolateId" }
, | 292 { DartNativeUtilitiesInternal::getNewIsolateId, 0, "Utils_getNewIsolateId" }
, |
| 263 { DartNativeUtilitiesInternal::spawnDomUri, 1, "Utils_spawnDomUri" }, | 293 { DartNativeUtilitiesInternal::spawnDomUri, 1, "Utils_spawnDomUri" }, |
| 294 { DartNativeUtilitiesInternal::resolveUri, 1, "Utils_resolvePackageUri" }, |
| 264 { 0, 0, 0 }, | 295 { 0, 0, 0 }, |
| 265 }; | 296 }; |
| 266 | 297 |
| 267 Dart_NativeFunction commonHtmlResolver(Dart_Handle name, int argumentCount, bool
* autoSetupScope) | 298 Dart_NativeFunction commonHtmlResolver(Dart_Handle name, int argumentCount, bool
* autoSetupScope) |
| 268 { | 299 { |
| 269 String str = DartUtilities::toString(name); | 300 String str = DartUtilities::toString(name); |
| 270 if (argumentCount == 2 && str == "Utils_spawnDomHelper") | 301 if (argumentCount == 2 && str == "Utils_spawnDomHelper") |
| 271 return DartNativeUtilitiesInternal::spawnDomHelper; | 302 return DartNativeUtilitiesInternal::spawnDomHelper; |
| 272 return 0; | 303 return 0; |
| 273 } | 304 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 if (nf == nativeEntries[i].nativeFunction) { | 342 if (nf == nativeEntries[i].nativeFunction) { |
| 312 return reinterpret_cast<const uint8_t*>(nativeEntries[i].name); | 343 return reinterpret_cast<const uint8_t*>(nativeEntries[i].name); |
| 313 } | 344 } |
| 314 } | 345 } |
| 315 | 346 |
| 316 return 0; | 347 return 0; |
| 317 } | 348 } |
| 318 | 349 |
| 319 | 350 |
| 320 } | 351 } |
| OLD | NEW |