Add Observatory to sky dart_controller
- Bump Dart and Observatory DEPS to 45576 and 45565 respectively.
- Include 'dart:io' in snapshot
- Add 'dart:io' native bindings to sky bindings.
- Initialize 'dart:io' in sky dart_controller.
- Include Observatory and service isolate resources in build.
- Bring up service isolate.
- Start handle watcher isolate from service isolate (hides handle watcher isolate from debugger and Observatory).
- Hook up debugger.
R=eseidel@chromium.org
Review URL: https://codereview.chromium.org/1107803002
diff --git a/mojo/dart/embedder/dart_debugger.cc b/mojo/dart/embedder/dart_debugger.cc
index 31e9ee4..684acc5 100644
--- a/mojo/dart/embedder/dart_debugger.cc
+++ b/mojo/dart/embedder/dart_debugger.cc
@@ -2,12 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <vector>
-
+#include "mojo/dart/embedder/dart_debugger.h"
#include "dart/runtime/include/dart_api.h"
#include "dart/runtime/include/dart_debugger_api.h"
#include "dart/runtime/include/dart_native_api.h"
-#include "mojo/dart/embedder/dart_debugger.h"
+
namespace mojo {
namespace dart {
@@ -45,10 +44,9 @@
intptr_t bp_id,
const Dart_CodeLocation& loc) {
Dart_EnterScope();
- DartDebuggerIsolate* debugger_isolate =
- FindIsolateById(isolate_id);
- CHECK(debugger_isolate != nullptr);
- debugger_isolate->MessageLoop();
+ intptr_t isolate_index = FindIsolateIndexById(isolate_id);
+ CHECK(isolate_index != -1);
+ (*isolates_)[isolate_index]->MessageLoop();
Dart_ExitScope();
}
@@ -56,10 +54,9 @@
Dart_Handle exception,
Dart_StackTrace stack_trace) {
Dart_EnterScope();
- DartDebuggerIsolate* debugger_isolate =
- FindIsolateById(isolate_id);
- CHECK(debugger_isolate != nullptr);
- debugger_isolate->MessageLoop();
+ intptr_t isolate_index = FindIsolateIndexById(isolate_id);
+ CHECK(isolate_index != -1);
+ (*isolates_)[isolate_index]->MessageLoop();
Dart_ExitScope();
}
@@ -69,11 +66,10 @@
if (kind == Dart_IsolateEvent::kCreated) {
AddIsolate(isolate_id);
} else {
- DartDebuggerIsolate* debugger_isolate =
- FindIsolateById(isolate_id);
- CHECK(debugger_isolate != nullptr);
+ intptr_t isolate_index = FindIsolateIndexById(isolate_id);
+ CHECK(isolate_index != -1);
if (kind == Dart_IsolateEvent::kInterrupted) {
- debugger_isolate->MessageLoop();
+ (*isolates_)[isolate_index]->MessageLoop();
} else {
CHECK(kind == Dart_IsolateEvent::kShutdown);
RemoveIsolate(isolate_id);
@@ -85,10 +81,9 @@
void DartDebugger::NotifyIsolate(Dart_Isolate isolate) {
base::AutoLock al(*lock_);
Dart_IsolateId isolate_id = Dart_GetIsolateId(isolate);
- DartDebuggerIsolate* debugger_isolate =
- FindIsolateByIdLocked(isolate_id);
- if (debugger_isolate != nullptr) {
- debugger_isolate->Notify();
+ intptr_t isolate_index = FindIsolateIndexByIdLocked(isolate_id);
+ if (isolate_index >= 0) {
+ (*isolates_)[isolate_index]->Notify();
}
}
@@ -98,40 +93,38 @@
Dart_SetBreakpointResolvedHandler(BptResolvedHandler);
Dart_SetExceptionThrownHandler(ExceptionThrownHandler);
lock_ = new base::Lock();
+ isolates_ = new std::vector<std::unique_ptr<DartDebuggerIsolate>>();
}
-DartDebuggerIsolate* DartDebugger::FindIsolateById(Dart_IsolateId id) {
+intptr_t DartDebugger::FindIsolateIndexById(Dart_IsolateId id) {
base::AutoLock al(*lock_);
- return FindIsolateByIdLocked(id);
+ return FindIsolateIndexByIdLocked(id);
}
-DartDebuggerIsolate* DartDebugger::FindIsolateByIdLocked(
+intptr_t DartDebugger::FindIsolateIndexByIdLocked(
Dart_IsolateId id) {
lock_->AssertAcquired();
- for (size_t i = 0; i < isolates_.size(); i++) {
- DartDebuggerIsolate* isolate = isolates_[i];
- if (id == isolate->id()) {
- return isolate;
+ for (size_t i = 0; i < isolates_->size(); i++) {
+ if ((*isolates_)[i]->id() == id) {
+ return i;
}
}
- return nullptr;
+ return -1;
}
-DartDebuggerIsolate* DartDebugger::AddIsolate(Dart_IsolateId id) {
+void DartDebugger::AddIsolate(Dart_IsolateId id) {
base::AutoLock al(*lock_);
- CHECK(FindIsolateByIdLocked(id) == nullptr);
- DartDebuggerIsolate* debugger_isolate =
- new DartDebuggerIsolate(id);
- isolates_.push_back(debugger_isolate);
- return debugger_isolate;
+ CHECK(FindIsolateIndexByIdLocked(id) == -1);
+ std::unique_ptr<DartDebuggerIsolate> debugger_isolate =
+ std::unique_ptr<DartDebuggerIsolate>(new DartDebuggerIsolate(id));
+ isolates_->push_back(std::move(debugger_isolate));
}
void DartDebugger::RemoveIsolate(Dart_IsolateId id) {
base::AutoLock al(*lock_);
- for (size_t i = 0; i < isolates_.size(); i++) {
- DartDebuggerIsolate* isolate = isolates_[i];
- if (id == isolate->id()) {
- isolates_.erase(isolates_.begin() + i);
+ for (size_t i = 0; i < isolates_->size(); i++) {
+ if (id == (*isolates_)[i]->id()) {
+ isolates_->erase(isolates_->begin() + i);
return;
}
}
@@ -139,7 +132,8 @@
}
base::Lock* DartDebugger::lock_ = nullptr;
-std::vector<DartDebuggerIsolate*> DartDebugger::isolates_;
+std::vector<std::unique_ptr<DartDebuggerIsolate>>* DartDebugger::isolates_ =
+ nullptr;
-} // namespace apps
+} // namespace dart
} // namespace mojo