Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
| 7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "lib/stacktrace.h" | 10 #include "lib/stacktrace.h" |
| 11 #include "vm/class_finalizer.h" | 11 #include "vm/class_finalizer.h" |
| 12 #include "vm/compiler.h" | 12 #include "vm/compiler.h" |
| 13 #include "vm/dart.h" | 13 #include "vm/dart.h" |
| 14 #include "vm/dart_api_impl.h" | 14 #include "vm/dart_api_impl.h" |
| 15 #include "vm/dart_api_message.h" | 15 #include "vm/dart_api_message.h" |
| 16 #include "vm/dart_api_state.h" | 16 #include "vm/dart_api_state.h" |
| 17 #include "vm/dart_entry.h" | 17 #include "vm/dart_entry.h" |
| 18 #include "vm/debugger.h" | 18 #include "vm/debugger.h" |
| 19 #include "vm/dev_fs.h" | |
| 19 #include "vm/exceptions.h" | 20 #include "vm/exceptions.h" |
| 20 #include "vm/flags.h" | 21 #include "vm/flags.h" |
| 21 #include "vm/growable_array.h" | 22 #include "vm/growable_array.h" |
| 22 #include "vm/lockers.h" | 23 #include "vm/lockers.h" |
| 23 #include "vm/message.h" | 24 #include "vm/message.h" |
| 24 #include "vm/message_handler.h" | 25 #include "vm/message_handler.h" |
| 25 #include "vm/native_entry.h" | 26 #include "vm/native_entry.h" |
| 26 #include "vm/object.h" | 27 #include "vm/object.h" |
| 27 #include "vm/object_store.h" | 28 #include "vm/object_store.h" |
| 28 #include "vm/os_thread.h" | 29 #include "vm/os_thread.h" |
| (...skipping 5859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5888 return Api::NewError("%s expects argument 'bytes_length' to be >= 0.", | 5889 return Api::NewError("%s expects argument 'bytes_length' to be >= 0.", |
| 5889 CURRENT_FUNC); | 5890 CURRENT_FUNC); |
| 5890 } | 5891 } |
| 5891 Service::SendEmbedderEvent(I, stream_id, event_kind, | 5892 Service::SendEmbedderEvent(I, stream_id, event_kind, |
| 5892 bytes, bytes_length); | 5893 bytes, bytes_length); |
| 5893 return Api::Success(); | 5894 return Api::Success(); |
| 5894 #endif // defined(PRODUCT) | 5895 #endif // defined(PRODUCT) |
| 5895 } | 5896 } |
| 5896 | 5897 |
| 5897 | 5898 |
| 5899 DART_EXPORT bool Dart_IsDevFSUri(Dart_Handle uri) { | |
| 5900 DARTSCOPE(Thread::Current()); | |
| 5901 const String& uri_string = Api::UnwrapStringHandle(Z, uri); | |
| 5902 if (uri_string.IsNull()) { | |
| 5903 return false; | |
| 5904 } | |
| 5905 ParsedUri parsed_uri; | |
| 5906 if (!ParseUri(uri_string.ToCString(), &parsed_uri)) { | |
| 5907 return false; | |
| 5908 } | |
| 5909 if ((parsed_uri.scheme == NULL) || | |
| 5910 (strcmp(parsed_uri.scheme, "dart-devfs") != 0)) { | |
| 5911 return false; | |
| 5912 } | |
| 5913 return true; | |
| 5914 } | |
| 5915 | |
| 5916 | |
| 5917 DART_EXPORT Dart_Handle Dart_DevFSReadFile(Dart_Handle uri) { | |
| 5918 DARTSCOPE(Thread::Current()); | |
| 5919 const String& uri_string = Api::UnwrapStringHandle(Z, uri); | |
| 5920 if (uri_string.IsNull()) { | |
| 5921 RETURN_TYPE_ERROR(Z, uri, String); | |
| 5922 } | |
| 5923 ParsedUri parsed_uri; | |
| 5924 if (!ParseUri(uri_string.ToCString(), &parsed_uri)) { | |
| 5925 return Api::NewError("%s: Unable to parse uri '%s'.", | |
| 5926 CURRENT_FUNC, uri_string.ToCString()); | |
| 5927 } | |
| 5928 if ((parsed_uri.scheme == NULL) || | |
| 5929 (strcmp(parsed_uri.scheme, "dart-devfs") != 0)) { | |
| 5930 return Api::NewError("%s: Not a dart-devfs uri '%s'.", | |
| 5931 CURRENT_FUNC, uri_string.ToCString()); | |
| 5932 } | |
| 5933 if (parsed_uri.host == NULL) { | |
| 5934 return Api::NewError("%s: Invalid dart-devfs uri '%s'.", | |
|
turnidge
2016/06/10 18:45:34
Make error message better. "No authority specified
| |
| 5935 CURRENT_FUNC, uri_string.ToCString()); | |
| 5936 } | |
| 5937 if (parsed_uri.path == NULL) { | |
| 5938 return Api::NewError("%s: No path specified in dart-devfs uri '%s'.", | |
| 5939 CURRENT_FUNC, uri_string.ToCString()); | |
| 5940 } | |
| 5941 return DevFS::ReadFile(parsed_uri.host, parsed_uri.path); | |
| 5942 } | |
| 5943 | |
| 5944 | |
| 5945 DART_EXPORT Dart_Handle Dart_DevFSReadFileAsUTF8String(Dart_Handle uri) { | |
| 5946 DARTSCOPE(Thread::Current()); | |
| 5947 const String& uri_string = Api::UnwrapStringHandle(Z, uri); | |
| 5948 if (uri_string.IsNull()) { | |
| 5949 RETURN_TYPE_ERROR(Z, uri, String); | |
| 5950 } | |
| 5951 ParsedUri parsed_uri; | |
| 5952 if (!ParseUri(uri_string.ToCString(), &parsed_uri)) { | |
| 5953 return Api::NewError("%s: Unable to parse uri '%s'.", | |
| 5954 CURRENT_FUNC, uri_string.ToCString()); | |
| 5955 } | |
| 5956 if ((parsed_uri.scheme == NULL) || | |
| 5957 (strcmp(parsed_uri.scheme, "dart-devfs") != 0)) { | |
| 5958 return Api::NewError("%s: Not a dart-devfs uri '%s'.", | |
| 5959 CURRENT_FUNC, uri_string.ToCString()); | |
| 5960 } | |
| 5961 if (parsed_uri.host == NULL) { | |
| 5962 return Api::NewError("%s: Invalid dart-devfs uri '%s'.", | |
| 5963 CURRENT_FUNC, uri_string.ToCString()); | |
| 5964 } | |
| 5965 if (parsed_uri.path == NULL) { | |
| 5966 return Api::NewError("%s: No path specified in dart-devfs uri '%s'.", | |
| 5967 CURRENT_FUNC, uri_string.ToCString()); | |
| 5968 } | |
| 5969 return DevFS::ReadFileAsString(parsed_uri.host, parsed_uri.path); | |
| 5970 } | |
| 5971 | |
| 5972 | |
| 5898 DART_EXPORT int64_t Dart_TimelineGetMicros() { | 5973 DART_EXPORT int64_t Dart_TimelineGetMicros() { |
| 5899 return OS::GetCurrentMonotonicMicros(); | 5974 return OS::GetCurrentMonotonicMicros(); |
| 5900 } | 5975 } |
| 5901 | 5976 |
| 5902 | 5977 |
| 5903 DART_EXPORT void Dart_GlobalTimelineSetRecordedStreams(int64_t stream_mask) { | 5978 DART_EXPORT void Dart_GlobalTimelineSetRecordedStreams(int64_t stream_mask) { |
| 5904 if (!FLAG_support_timeline) { | 5979 if (!FLAG_support_timeline) { |
| 5905 return; | 5980 return; |
| 5906 } | 5981 } |
| 5907 const bool api_enabled = (stream_mask & DART_TIMELINE_STREAM_API) != 0; | 5982 const bool api_enabled = (stream_mask & DART_TIMELINE_STREAM_API) != 0; |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6439 | 6514 |
| 6440 DART_EXPORT bool Dart_IsPrecompiledRuntime() { | 6515 DART_EXPORT bool Dart_IsPrecompiledRuntime() { |
| 6441 #if defined(DART_PRECOMPILED_RUNTIME) | 6516 #if defined(DART_PRECOMPILED_RUNTIME) |
| 6442 return true; | 6517 return true; |
| 6443 #else | 6518 #else |
| 6444 return false; | 6519 return false; |
| 6445 #endif | 6520 #endif |
| 6446 } | 6521 } |
| 6447 | 6522 |
| 6448 } // namespace dart | 6523 } // namespace dart |
| OLD | NEW |