OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "bin/dartutils.h" | 5 #include "bin/dartutils.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 | 8 |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/globals.h" | 10 #include "platform/globals.h" |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 if (Dart_IsError(source)) { | 536 if (Dart_IsError(source)) { |
537 return source; | 537 return source; |
538 } | 538 } |
539 return Dart_LoadScript(uri, source, 0, 0); | 539 return Dart_LoadScript(uri, source, 0, 0); |
540 } | 540 } |
541 } | 541 } |
542 | 542 |
543 | 543 |
544 Dart_Handle DartUtils::LoadScript(const char* script_uri, | 544 Dart_Handle DartUtils::LoadScript(const char* script_uri, |
545 Dart_Handle builtin_lib) { | 545 Dart_Handle builtin_lib) { |
546 if (DartUtils::IsHttpSchemeURL(script_uri)) { | 546 // Always call ResolveScriptUri because as a side effect it sets |
547 return LoadScriptHttp(NewString(script_uri), builtin_lib); | 547 // the script entry path which is used when automatically resolving |
548 } | 548 // package root. |
549 Dart_Handle resolved_script_uri; | 549 Dart_Handle resolved_script_uri = |
550 resolved_script_uri = ResolveScriptUri(NewString(script_uri), builtin_lib); | 550 ResolveScriptUri(NewString(script_uri), builtin_lib); |
551 if (Dart_IsError(resolved_script_uri)) { | 551 if (Dart_IsError(resolved_script_uri)) { |
552 return resolved_script_uri; | 552 return resolved_script_uri; |
553 } | 553 } |
| 554 // Handle http: requests separately. |
| 555 if (DartUtils::IsHttpSchemeURL(script_uri)) { |
| 556 return LoadScriptHttp(resolved_script_uri, builtin_lib); |
| 557 } |
554 Dart_Handle script_path = DartUtils::FilePathFromUri(resolved_script_uri, | 558 Dart_Handle script_path = DartUtils::FilePathFromUri(resolved_script_uri, |
555 builtin_lib); | 559 builtin_lib); |
556 if (Dart_IsError(script_path)) { | 560 if (Dart_IsError(script_path)) { |
557 return script_path; | 561 return script_path; |
558 } | 562 } |
559 const char* script_path_cstr; | 563 const char* script_path_cstr; |
560 Dart_StringToCString(script_path, &script_path_cstr); | 564 Dart_StringToCString(script_path, &script_path_cstr); |
561 const char* error_msg = NULL; | 565 const char* error_msg = NULL; |
562 intptr_t len; | 566 intptr_t len; |
563 const uint8_t* text_buffer = ReadFileFully(script_path_cstr, | 567 const uint8_t* text_buffer = ReadFileFully(script_path_cstr, |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 new CObjectString(CObject::NewString(os_error->message())); | 937 new CObjectString(CObject::NewString(os_error->message())); |
934 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 938 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
935 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 939 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
936 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 940 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
937 result->SetAt(2, error_message); | 941 result->SetAt(2, error_message); |
938 return result; | 942 return result; |
939 } | 943 } |
940 | 944 |
941 } // namespace bin | 945 } // namespace bin |
942 } // namespace dart | 946 } // namespace dart |
OLD | NEW |