Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 | 79 |
| 80 void DartApplicationLoader::reportDartError(Dart_Handle error) | 80 void DartApplicationLoader::reportDartError(Dart_Handle error) |
| 81 { | 81 { |
| 82 m_scriptHasError = true; | 82 m_scriptHasError = true; |
| 83 DartUtilities::reportProblem(m_originDocument, error, m_libraryUrl); | 83 DartUtilities::reportProblem(m_originDocument, error, m_libraryUrl); |
| 84 } | 84 } |
| 85 | 85 |
| 86 Dart_Handle DartApplicationLoader::libraryTagHandlerCallback(Dart_LibraryTag tag , Dart_Handle library, Dart_Handle urlHandle) | 86 Dart_Handle DartApplicationLoader::libraryTagHandlerCallback(Dart_LibraryTag tag , Dart_Handle library, Dart_Handle urlHandle) |
| 87 { | 87 { |
| 88 ASSERT(Dart_CurrentIsolate()); | 88 ASSERT(Dart_CurrentIsolate()); |
| 89 ASSERT(DartDOMData::current()->applicationLoader()); | |
| 90 return DartDOMData::current()->applicationLoader()->libraryTagHandler(tag, l ibrary, urlHandle); | |
|
kustermann
2013/07/10 13:50:39
(Sidenote: AFAIK the styleguide allows long lines,
| |
| 91 } | |
| 92 | |
| 93 Dart_Handle DartApplicationLoader::libraryTagHandler(Dart_LibraryTag tag, Dart_H andle library, Dart_Handle urlHandle) | |
| 94 { | |
| 95 ASSERT(Dart_IsLibrary(library)); | 89 ASSERT(Dart_IsLibrary(library)); |
| 96 | 90 |
| 97 const String url = DartUtilities::toString(urlHandle); | 91 const String url = DartUtilities::toString(urlHandle); |
| 98 | 92 |
| 99 Dart_Handle libraryURLHandle = Dart_LibraryUrl(library); | 93 Dart_Handle libraryURLHandle = Dart_LibraryUrl(library); |
| 100 ASSERT(!Dart_IsError(libraryURLHandle)); | 94 ASSERT(!Dart_IsError(libraryURLHandle)); |
| 101 String libraryURL = DartUtilities::toString(libraryURLHandle); | 95 String libraryURL = DartUtilities::toString(libraryURLHandle); |
|
siva
2013/07/10 18:10:26
Why does this library to libraryURL translation ha
kustermann
2013/07/11 12:34:11
Done.
| |
| 102 | 96 |
| 103 if (tag == Dart_kCanonicalizeUrl) { | 97 if (tag == Dart_kCanonicalizeUrl) { |
| 104 if (url.startsWith("dart:") || url.startsWith("package:")) | 98 // If a dart application calls spawnUri, the DartVM will call this |
| 105 return urlHandle; | 99 // libraryTagHandler to canonicalize the url. |
| 100 // DartDOMData::current()->applicationLoader() may be NULL at this poi nt. | |
| 101 return DartApplicationLoader::CanonicalizeUrl(urlHandle, url, libraryU RL); | |
| 102 } else { | |
| 103 ASSERT(DartDOMData::current()->applicationLoader()); | |
| 104 return DartDOMData::current()->applicationLoader()->libraryTagHandler( tag, urlHandle, url, libraryURL); | |
|
siva
2013/07/10 18:10:26
Similarly change the signature of libraryTagHandle
kustermann
2013/07/11 12:34:11
Done.
| |
| 105 } | |
| 106 } | |
| 106 | 107 |
| 107 bool packageScheme = false; | 108 Dart_Handle DartApplicationLoader::CanonicalizeUrl(Dart_Handle urlHandle, String url, String libraryURL) |
| 108 if (libraryURL.startsWith("package:")) { | 109 { |
| 109 // KURL have problems concating package:foo/bar (without slashes rig ht after colon) | 110 if (url.startsWith("dart:") || url.startsWith("package:")) |
| 110 // and relative urls. Therefore pretend to be a standard absolute UR L. | 111 return urlHandle; |
| 111 packageScheme = true; | |
| 112 libraryURL = "http://" + libraryURL.substring(8); | |
| 113 } | |
| 114 | 112 |
| 115 const KURL canonical = KURL(KURL(KURL(), libraryURL), url); | 113 bool packageScheme = false; |
| 116 String result = canonical.string(); | 114 if (libraryURL.startsWith("package:")) { |
| 117 if (packageScheme) | 115 // KURL have problems concating package:foo/bar (without slashes right a fter colon) |
|
siva
2013/07/10 18:10:26
KURL has problems......
kustermann
2013/07/11 12:34:11
Done.
| |
| 118 result = "package:" + result.substring(7); | 116 // and relative urls. Therefore pretend to be a standard absolute URL. |
| 119 return DartUtilities::stringToDartString(result); | 117 packageScheme = true; |
| 118 libraryURL = "http://" + libraryURL.substring(8); | |
|
siva
2013/07/10 18:10:26
These magic numbers 8, 7 etc. make me uncomfortabl
kustermann
2013/07/11 12:34:11
Done.
| |
| 120 } | 119 } |
| 121 | 120 |
| 121 const KURL canonical = KURL(KURL(KURL(), libraryURL), url); | |
| 122 String result = canonical.string(); | |
| 123 if (packageScheme) | |
| 124 result = "package:" + result.substring(7); | |
| 125 return DartUtilities::stringToDartString(result); | |
| 126 } | |
| 127 | |
| 128 Dart_Handle DartApplicationLoader::libraryTagHandler(Dart_LibraryTag tag, Dart_H andle urlHandle, String url, String libraryURL) | |
| 129 { | |
| 122 ASSERT(url != "dart:html"); | 130 ASSERT(url != "dart:html"); |
| 123 | 131 |
| 124 // Record the importer. | 132 // Record the importer. |
| 125 if (tag == Dart_kImportTag) | 133 if (tag == Dart_kImportTag) |
| 126 m_importedLibraries.add(url); | 134 m_importedLibraries.add(url); |
| 127 else if (tag == Dart_kSourceTag) | 135 else if (tag == Dart_kSourceTag) |
| 128 add(m_importersForSource, url, libraryURL); | 136 add(m_importersForSource, url, libraryURL); |
| 129 else | 137 else |
| 130 ASSERT_NOT_REACHED(); | 138 ASSERT_NOT_REACHED(); |
| 131 | 139 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 383 // We should never have a self dependence. | 391 // We should never have a self dependence. |
| 384 ASSERT(key != value); | 392 ASSERT(key != value); |
| 385 UrlMultiMap::iterator iter = map.find(key); | 393 UrlMultiMap::iterator iter = map.find(key); |
| 386 if (iter == map.end()) | 394 if (iter == map.end()) |
| 387 iter = map.add(key, new UrlSet()).iterator; | 395 iter = map.add(key, new UrlSet()).iterator; |
| 388 UrlSet* set = iter->value; | 396 UrlSet* set = iter->value; |
| 389 set->add(value); | 397 set->add(value); |
| 390 } | 398 } |
| 391 | 399 |
| 392 } | 400 } |
| OLD | NEW |