Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1171)

Unified Diff: runtime/vm/service.cc

Issue 243973002: - Add a minimal implementation of Capability. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/raw_object_snapshot.cc ('k') | runtime/vm/service_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/service.cc
===================================================================
--- runtime/vm/service.cc (revision 35287)
+++ 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();
}
@@ -262,9 +249,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));
- ASSERT(!send_port.IsNull());
+ const SendPort& send_port = SendPort::Handle(SendPort::New(port_id));
list.SetAt(0, code_int);
list.SetAt(1, port_int);
list.SetAt(2, send_port);
@@ -305,9 +290,7 @@
intptr_t port_id = isolate->main_port();
const Integer& port_int = Integer::Handle(Integer::New(port_id));
ASSERT(!port_int.IsNull());
- const Object& send_port = Object::Handle(
- DartLibraryCalls::NewSendPort(port_id));
- ASSERT(!send_port.IsNull());
+ const SendPort& send_port = SendPort::Handle(SendPort::New(port_id));
const String& name = String::Handle(String::New(isolate->name()));
ASSERT(!name.IsNull());
const Array& args = Array::Handle(Array::New(3));
@@ -661,6 +644,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);
@@ -674,7 +661,8 @@
FindIsolateMessageHandler(path_segment_c);
{
JSONStream js;
- js.Setup(zone.GetZone(), reply_port, path, option_keys, option_values);
+ js.Setup(zone.GetZone(), SendPort::Cast(reply_port).Id(),
+ path, option_keys, option_values);
if (handler == NULL) {
// Check for an embedder handler.
EmbedderServiceHandler* e_handler =
@@ -1758,6 +1746,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);
@@ -1771,6 +1760,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);
@@ -1784,7 +1777,8 @@
FindRootMessageHandler(path_segment_c);
{
JSONStream js;
- js.Setup(zone.GetZone(), reply_port, path, option_keys, option_values);
+ js.Setup(zone.GetZone(), SendPort::Cast(reply_port).Id(),
+ path, option_keys, option_values);
if (handler == NULL) {
// Check for an embedder handler.
EmbedderServiceHandler* e_handler =
« no previous file with comments | « runtime/vm/raw_object_snapshot.cc ('k') | runtime/vm/service_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698