Chromium Code Reviews| Index: runtime/vm/service.cc |
| =================================================================== |
| --- runtime/vm/service.cc (revision 35191) |
| +++ runtime/vm/service.cc (working copy) |
| @@ -158,26 +158,16 @@ |
| Isolate* isolate = arguments->isolate(); |
| StackZone zone(isolate); |
| HANDLESCOPE(isolate); |
| - GET_NON_NULL_NATIVE_ARGUMENT(Instance, sp, arguments->NativeArgAt(0)); |
| + GET_NON_NULL_NATIVE_ARGUMENT(SendPort, sp, arguments->NativeArgAt(0)); |
| GET_NON_NULL_NATIVE_ARGUMENT(Instance, message, arguments->NativeArgAt(1)); |
| - // Extract SendPort port id. |
| - const Object& sp_id_obj = Object::Handle(DartLibraryCalls::PortGetId(sp)); |
| - if (sp_id_obj.IsError()) { |
| - Exceptions::PropagateError(Error::Cast(sp_id_obj)); |
| - } |
| - Integer& id = Integer::Handle(isolate); |
| - id ^= sp_id_obj.raw(); |
| - Dart_Port sp_id = static_cast<Dart_Port>(id.AsInt64Value()); |
| - ASSERT(sp_id != ILLEGAL_PORT); |
| - |
| // Serialize message. |
| uint8_t* data = NULL; |
| MessageWriter writer(&data, &allocator); |
| writer.WriteMessage(message); |
| // TODO(turnidge): Throw an exception when the return value is false? |
| - PortMap::PostMessage(new Message(sp_id, data, writer.BytesWritten(), |
| + PortMap::PostMessage(new Message(sp.Id(), data, writer.BytesWritten(), |
| Message::kOOBPriority)); |
| } |
| @@ -241,13 +231,10 @@ |
| const Object& unwrapped_rp = Object::Handle(Api::UnwrapHandle(receivePort)); |
| const Instance& rp = Instance::Cast(unwrapped_rp); |
| // Extract RawReceivePort port id. |
| - const Object& rp_id_obj = Object::Handle(DartLibraryCalls::PortGetId(rp)); |
| - if (rp_id_obj.IsError()) { |
| + if (!rp.IsReceivePort()) { |
| return ILLEGAL_PORT; |
| } |
| - ASSERT(rp_id_obj.IsSmi() || rp_id_obj.IsMint()); |
| - const Integer& id = Integer::Cast(rp_id_obj); |
| - return static_cast<Dart_Port>(id.AsInt64Value()); |
| + return ReceivePort::Cast(rp).Id(); |
| } |
| @@ -345,8 +332,7 @@ |
| ASSERT(!list.IsNull()); |
| const Integer& code_int = Integer::Handle(Integer::New(code)); |
| const Integer& port_int = Integer::Handle(Integer::New(port_id)); |
| - const Object& send_port = Object::Handle( |
| - DartLibraryCalls::NewSendPort(port_id)); |
| + const SendPort& send_port = SendPort::Handle(SendPort::New(port_id)); |
| ASSERT(!send_port.IsNull()); |
| list.SetAt(0, code_int); |
| list.SetAt(1, port_int); |
| @@ -601,6 +587,10 @@ |
| // Same number of option keys as values. |
| ASSERT(option_keys.Length() == option_values.Length()); |
| + if (!reply_port.IsSendPort()) { |
| + FATAL("SendPort expected."); |
| + } |
| + |
| String& path_segment = String::Handle(); |
| if (path.Length() > 0) { |
| path_segment ^= path.At(0); |
| @@ -614,7 +604,8 @@ |
| FindIsolateMessageHandler(path_segment_c); |
| { |
| JSONStream js; |
| - js.Setup(zone.GetZone(), reply_port, path, option_keys, option_values); |
| + js.Setup(zone.GetZone(), SendPort::Cast( |
|
turnidge
2014/04/22 18:40:45
strange line break.
Ivan Posva
2014/04/22 21:28:30
Changed, but there is no good way to make this fit
|
| + reply_port).Id(), path, option_keys, option_values); |
| if (handler == NULL) { |
| // Check for an embedder handler. |
| EmbedderServiceHandler* e_handler = |
| @@ -1689,6 +1680,7 @@ |
| GrowableObjectArray& path = GrowableObjectArray::Handle(isolate); |
| GrowableObjectArray& option_keys = GrowableObjectArray::Handle(isolate); |
| GrowableObjectArray& option_values = GrowableObjectArray::Handle(isolate); |
| + |
| reply_port ^= message.At(0); |
| path ^= message.At(1); |
| option_keys ^= message.At(2); |
| @@ -1702,6 +1694,10 @@ |
| // Same number of option keys as values. |
| ASSERT(option_keys.Length() == option_values.Length()); |
| + if (!reply_port.IsSendPort()) { |
| + FATAL("SendPort expected."); |
|
Cutch
2014/04/22 20:15:22
Why not ASSERT(reply_port.IsSendPort()) here and a
|
| + } |
| + |
| String& path_segment = String::Handle(); |
| if (path.Length() > 0) { |
| path_segment ^= path.At(0); |
| @@ -1715,7 +1711,8 @@ |
| FindRootMessageHandler(path_segment_c); |
| { |
| JSONStream js; |
| - js.Setup(zone.GetZone(), reply_port, path, option_keys, option_values); |
| + js.Setup(zone.GetZone(), SendPort::Cast( |
|
turnidge
2014/04/22 18:40:45
ditto
|
| + reply_port).Id(), path, option_keys, option_values); |
| if (handler == NULL) { |
| // Check for an embedder handler. |
| EmbedderServiceHandler* e_handler = |