| 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 "vm/service.h" | 5 #include "vm/service.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
| 9 #include "platform/globals.h" | 9 #include "platform/globals.h" |
| 10 | 10 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 } | 135 } |
| 136 intptr_t num_streams = sizeof(streams_) / | 136 intptr_t num_streams = sizeof(streams_) / |
| 137 sizeof(streams_[0]); | 137 sizeof(streams_[0]); |
| 138 for (intptr_t i = 0; i < num_streams; i++) { | 138 for (intptr_t i = 0; i < num_streams; i++) { |
| 139 if (strcmp(stream_id, streams_[i]->id()) == 0) { | 139 if (strcmp(stream_id, streams_[i]->id()) == 0) { |
| 140 streams_[i]->set_enabled(true); | 140 streams_[i]->set_enabled(true); |
| 141 return true; | 141 return true; |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 if (stream_listen_callback_) { | 144 if (stream_listen_callback_) { |
| 145 Thread* T = Thread::Current(); |
| 146 TransitionVMToNative transition(T); |
| 145 return (*stream_listen_callback_)(stream_id); | 147 return (*stream_listen_callback_)(stream_id); |
| 146 } | 148 } |
| 147 return false; | 149 return false; |
| 148 } | 150 } |
| 149 | 151 |
| 150 | 152 |
| 151 void Service::CancelStream(const char* stream_id) { | 153 void Service::CancelStream(const char* stream_id) { |
| 152 if (FLAG_trace_service) { | 154 if (FLAG_trace_service) { |
| 153 OS::Print("vm-service: stopping stream '%s'\n", | 155 OS::Print("vm-service: stopping stream '%s'\n", |
| 154 stream_id); | 156 stream_id); |
| 155 } | 157 } |
| 156 intptr_t num_streams = sizeof(streams_) / | 158 intptr_t num_streams = sizeof(streams_) / |
| 157 sizeof(streams_[0]); | 159 sizeof(streams_[0]); |
| 158 for (intptr_t i = 0; i < num_streams; i++) { | 160 for (intptr_t i = 0; i < num_streams; i++) { |
| 159 if (strcmp(stream_id, streams_[i]->id()) == 0) { | 161 if (strcmp(stream_id, streams_[i]->id()) == 0) { |
| 160 streams_[i]->set_enabled(false); | 162 streams_[i]->set_enabled(false); |
| 161 return; | 163 return; |
| 162 } | 164 } |
| 163 } | 165 } |
| 164 if (stream_cancel_callback_) { | 166 if (stream_cancel_callback_) { |
| 167 Thread* T = Thread::Current(); |
| 168 TransitionVMToNative transition(T); |
| 165 return (*stream_cancel_callback_)(stream_id); | 169 return (*stream_cancel_callback_)(stream_id); |
| 166 } | 170 } |
| 167 } | 171 } |
| 168 | 172 |
| 169 RawObject* Service::RequestAssets() { | 173 RawObject* Service::RequestAssets() { |
| 170 Thread* T = Thread::Current(); | 174 Thread* T = Thread::Current(); |
| 175 TransitionVMToNative transition(T); |
| 171 Api::Scope api_scope(T); | 176 Api::Scope api_scope(T); |
| 172 if (get_service_assets_callback_ == NULL) { | 177 if (get_service_assets_callback_ == NULL) { |
| 173 return Object::null(); | 178 return Object::null(); |
| 174 } | 179 } |
| 175 Dart_Handle handle = get_service_assets_callback_(); | 180 Dart_Handle handle = get_service_assets_callback_(); |
| 176 if (Dart_IsError(handle)) { | 181 if (Dart_IsError(handle)) { |
| 177 Dart_PropagateError(handle); | 182 Dart_PropagateError(handle); |
| 178 } | 183 } |
| 179 const Object& object = Object::Handle(Api::UnwrapHandle(handle)); | 184 const Object& object = Object::Handle(Api::UnwrapHandle(handle)); |
| 180 if (object.IsNull()) { | 185 if (object.IsNull()) { |
| (...skipping 3685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3866 const ServiceMethodDescriptor& method = service_methods_[i]; | 3871 const ServiceMethodDescriptor& method = service_methods_[i]; |
| 3867 if (strcmp(method_name, method.name) == 0) { | 3872 if (strcmp(method_name, method.name) == 0) { |
| 3868 return &method; | 3873 return &method; |
| 3869 } | 3874 } |
| 3870 } | 3875 } |
| 3871 return NULL; | 3876 return NULL; |
| 3872 } | 3877 } |
| 3873 | 3878 |
| 3874 | 3879 |
| 3875 } // namespace dart | 3880 } // namespace dart |
| OLD | NEW |