Chromium Code Reviews| Index: runtime/vm/service_isolate.cc |
| diff --git a/runtime/vm/service_isolate.cc b/runtime/vm/service_isolate.cc |
| index c9a47c2418d3fd8efe0268813c6e2e544d332988..dc78c84a245a91287b887bd4d71288bad5c377fe 100644 |
| --- a/runtime/vm/service_isolate.cc |
| +++ b/runtime/vm/service_isolate.cc |
| @@ -149,6 +149,7 @@ const char* ServiceIsolate::kName = "vm-service"; |
| Isolate* ServiceIsolate::isolate_ = NULL; |
| Dart_Port ServiceIsolate::port_ = ILLEGAL_PORT; |
| Dart_Port ServiceIsolate::load_port_ = ILLEGAL_PORT; |
| +Dart_Port ServiceIsolate::origin_ = ILLEGAL_PORT; |
| Dart_IsolateCreateCallback ServiceIsolate::create_callback_ = NULL; |
| uint8_t* ServiceIsolate::exit_message_ = NULL; |
| intptr_t ServiceIsolate::exit_message_length_ = 0; |
| @@ -181,8 +182,9 @@ class RegisterRunningIsolatesVisitor : public IsolateVisitor { |
| virtual void VisitIsolate(Isolate* isolate) { |
| ASSERT(ServiceIsolate::IsServiceIsolate(Isolate::Current())); |
| if (ServiceIsolate::IsServiceIsolate(isolate) || |
| - (isolate == Dart::vm_isolate())) { |
| - // We do not register the service or vm isolate. |
| + (isolate == Dart::vm_isolate()) || |
| + (isolate->origin_id() == ServiceIsolate::Origin())) { |
|
turnidge
2015/04/01 19:57:34
Can this whole test get replaces by ServiceIsolate
Cutch
2015/04/01 20:19:04
Done.
|
| + // We do not register the service (and descendants) or the vm-isolate. |
| return; |
| } |
| // Setup arguments for call. |
| @@ -281,6 +283,7 @@ class ServiceIsolateNatives : public AllStatic { |
| Dart_Port port = ExtractPort(isolate, result); |
| ASSERT(port != ILLEGAL_PORT); |
| ServiceIsolate::SetServicePort(port); |
| + ServiceIsolate::SetOrigin(isolate->origin_id()); |
| Dart_ExitScope(); |
| } |
| @@ -377,11 +380,22 @@ bool ServiceIsolate::IsServiceIsolate(Isolate* isolate) { |
| } |
| +bool ServiceIsolate::IsServiceIsolateDescendant(Isolate* isolate) { |
| + MonitorLocker ml(monitor_); |
| + return isolate->origin_id() == origin_; |
| +} |
| + |
| + |
| Dart_Port ServiceIsolate::Port() { |
| MonitorLocker ml(monitor_); |
| return port_; |
| } |
| +Dart_Port ServiceIsolate::Origin() { |
| + MonitorLocker ml(monitor_); |
| + return origin_; |
| +} |
| + |
| Dart_Port ServiceIsolate::WaitForLoadPort() { |
| MonitorLocker ml(monitor_); |
| @@ -405,7 +419,7 @@ bool ServiceIsolate::SendIsolateStartupMessage() { |
| return false; |
| } |
| Isolate* isolate = Isolate::Current(); |
| - if (IsServiceIsolate(isolate)) { |
| + if (IsServiceIsolate(isolate) || IsServiceIsolateDescendant(isolate)) { |
|
turnidge
2015/04/01 19:57:34
Collapse and ditto below.
Cutch
2015/04/01 20:19:04
Done.
|
| return false; |
| } |
| ASSERT(isolate != NULL); |
| @@ -436,7 +450,7 @@ bool ServiceIsolate::SendIsolateShutdownMessage() { |
| return false; |
| } |
| Isolate* isolate = Isolate::Current(); |
| - if (IsServiceIsolate(isolate)) { |
| + if (IsServiceIsolate(isolate) || IsServiceIsolateDescendant(isolate)) { |
| return false; |
| } |
| ASSERT(isolate != NULL); |
| @@ -479,6 +493,12 @@ void ServiceIsolate::SendServiceExitMessage() { |
| } |
| +void ServiceIsolate::SetOrigin(Dart_Port origin) { |
| + MonitorLocker ml(monitor_); |
| + origin_ = origin; |
| +} |
| + |
| + |
| void ServiceIsolate::SetServicePort(Dart_Port port) { |
| MonitorLocker ml(monitor_); |
| port_ = port; |
| @@ -649,6 +669,7 @@ class RunServiceTask : public ThreadPool::Task { |
| } |
| ServiceIsolate::SetServiceIsolate(NULL); |
| ServiceIsolate::SetServicePort(ILLEGAL_PORT); |
| + ServiceIsolate::SetOrigin(ILLEGAL_PORT); |
| if (FLAG_trace_service) { |
| OS::Print("vm-service: Shutdown.\n"); |
| } |