Enable Observatory debugger for Mojo embedder

- Add Monitor and MonitorLocker classes.
- Add DartControllerDebuggerIsolate (one per isolate registered with debugger)
- Add DartControllerDebugger (owner of DartControllerDebuggerIsolates and implementation of debug message loop).

R=zra@google.com

Review URL: https://codereview.chromium.org/1093363005
diff --git a/mojo/dart/embedder/dart_debugger.h b/mojo/dart/embedder/dart_debugger.h
new file mode 100644
index 0000000..fe7ef2d
--- /dev/null
+++ b/mojo/dart/embedder/dart_debugger.h
@@ -0,0 +1,80 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_DART_EMBEDDER_DART_DEBUGGER_H_
+#define 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/monitor.h"
+
+namespace base {
+  class Lock;
+}
+
+namespace mojo {
+namespace dart {
+
+class DartDebuggerIsolate {
+ public:
+  DartDebuggerIsolate(Dart_IsolateId id)
+      : id_(id) {
+  }
+
+  Dart_IsolateId id() const {
+    return id_;
+  }
+
+  void Notify() {
+    monitor_.Notify();
+  }
+
+  void MessageLoop();
+
+ private:
+  const Dart_IsolateId id_;
+  Monitor monitor_;
+};
+
+class DartDebugger {
+ public:
+  static void InitDebugger();
+
+ private:
+  static void BptResolvedHandler(Dart_IsolateId isolate_id,
+                                 intptr_t bp_id,
+                                 const Dart_CodeLocation& location);
+
+  static void PausedEventHandler(Dart_IsolateId isolate_id,
+                                 intptr_t bp_id,
+                                 const Dart_CodeLocation& loc);
+
+  static void ExceptionThrownHandler(Dart_IsolateId isolate_id,
+                                     Dart_Handle exception,
+                                     Dart_StackTrace stack_trace);
+
+  static void IsolateEventHandler(Dart_IsolateId isolate_id,
+                                  Dart_IsolateEvent kind);
+
+  static void NotifyIsolate(Dart_Isolate isolate);
+
+  static DartDebuggerIsolate* FindIsolateById(Dart_IsolateId id);
+
+  static DartDebuggerIsolate* FindIsolateByIdLocked(Dart_IsolateId id);
+
+  static DartDebuggerIsolate* AddIsolate(Dart_IsolateId id);
+
+  static void RemoveIsolate(Dart_IsolateId id);
+
+  static base::Lock* lock_;
+  static std::vector<DartDebuggerIsolate*> isolates_;
+
+  friend class DartDebuggerIsolate;
+};
+
+}  // namespace dart
+}  // namespace mojo
+
+#endif  // MOJO_DART_EMBEDDER_DART_DEBUGGER_H_
\ No newline at end of file