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 "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
(...skipping 5674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5685 | 5685 |
5686 | 5686 |
5687 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 5687 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
5688 const char* name, | 5688 const char* name, |
5689 Dart_ServiceRequestCallback callback, | 5689 Dart_ServiceRequestCallback callback, |
5690 void* user_data) { | 5690 void* user_data) { |
5691 Service::RegisterRootEmbedderCallback(name, callback, user_data); | 5691 Service::RegisterRootEmbedderCallback(name, callback, user_data); |
5692 } | 5692 } |
5693 | 5693 |
5694 | 5694 |
5695 DART_EXPORT Dart_Handle Dart_SetServiceStreamCallbacks( | |
5696 Dart_ServiceStreamListenCallback listen_callback, | |
5697 Dart_ServiceStreamCancelCallback cancel_callback) { | |
5698 if (listen_callback != NULL) { | |
5699 if (Service::stream_listen_callback() != NULL) { | |
5700 return Api::NewError( | |
5701 "%s permits only one listen callback to be registered, please " | |
5702 "remove the existing callback and then add this callback", | |
5703 CURRENT_FUNC); | |
5704 } | |
5705 } else { | |
5706 if (Service::stream_listen_callback() == NULL) { | |
5707 return Api::NewError( | |
5708 "%s expects 'listen_callback' to be present in the callback set.", | |
5709 CURRENT_FUNC); | |
5710 } | |
5711 } | |
5712 if (cancel_callback != NULL) { | |
5713 if (Service::stream_cancel_callback() != NULL) { | |
5714 return Api::NewError( | |
Cutch
2015/07/13 14:10:29
Do we need to be this careful? Can't we just alway
turnidge
2015/07/13 22:50:36
I was going for consistency with the gc prologue a
| |
5715 "%s permits only one cancel callback to be registered, please " | |
5716 "remove the existing callback and then add this callback", | |
5717 CURRENT_FUNC); | |
5718 } | |
5719 } else { | |
5720 if (Service::stream_cancel_callback() == NULL) { | |
5721 return Api::NewError( | |
5722 "%s expects 'cancel_callback' to be present in the callback set.", | |
5723 CURRENT_FUNC); | |
5724 } | |
5725 } | |
5726 Service::SetEmbedderStreamCallbacks(listen_callback, cancel_callback); | |
5727 return Api::Success(); | |
5728 } | |
5729 | |
5730 | |
5731 DART_EXPORT Dart_Handle Dart_ServiceSendDataEvent(const char* stream_id, | |
5732 const char* event_kind, | |
5733 const uint8_t* bytes, | |
5734 intptr_t bytes_length) { | |
5735 Isolate* isolate = Isolate::Current(); | |
5736 DARTSCOPE(isolate); | |
5737 if (stream_id == NULL) { | |
5738 RETURN_NULL_ERROR(stream_id); | |
5739 } | |
5740 if (event_kind == NULL) { | |
5741 RETURN_NULL_ERROR(event_kind); | |
5742 } | |
5743 if (bytes == NULL) { | |
5744 RETURN_NULL_ERROR(bytes); | |
5745 } | |
5746 if (bytes_length < 0) { | |
5747 return Api::NewError("%s expects argument 'bytes_length' to be >= 0.", | |
5748 CURRENT_FUNC); | |
5749 } | |
5750 Service::SendEmbedderEvent(isolate, stream_id, event_kind, | |
5751 bytes, bytes_length); | |
5752 return Api::Success(); | |
5753 } | |
5754 | |
5755 | |
5695 DART_EXPORT Dart_Handle Dart_TimelineDuration(const char* label, | 5756 DART_EXPORT Dart_Handle Dart_TimelineDuration(const char* label, |
5696 int64_t start_micros, | 5757 int64_t start_micros, |
5697 int64_t end_micros) { | 5758 int64_t end_micros) { |
5698 Isolate* isolate = Isolate::Current(); | 5759 Isolate* isolate = Isolate::Current(); |
5699 CHECK_ISOLATE(isolate); | 5760 CHECK_ISOLATE(isolate); |
5700 if (label == NULL) { | 5761 if (label == NULL) { |
5701 RETURN_NULL_ERROR(label); | 5762 RETURN_NULL_ERROR(label); |
5702 } | 5763 } |
5703 if (start_micros > end_micros) { | 5764 if (start_micros > end_micros) { |
5704 const char* msg = "%s: start_micros must be <= end_micros"; | 5765 const char* msg = "%s: start_micros must be <= end_micros"; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5789 ASSERT(stream != NULL); | 5850 ASSERT(stream != NULL); |
5790 TimelineEvent* event = stream->StartEvent(); | 5851 TimelineEvent* event = stream->StartEvent(); |
5791 if (event != NULL) { | 5852 if (event != NULL) { |
5792 event->AsyncEnd(label, async_id); | 5853 event->AsyncEnd(label, async_id); |
5793 event->Complete(); | 5854 event->Complete(); |
5794 } | 5855 } |
5795 return Api::Success(); | 5856 return Api::Success(); |
5796 } | 5857 } |
5797 | 5858 |
5798 } // namespace dart | 5859 } // namespace dart |
OLD | NEW |