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

Side by Side Diff: sky/engine/core/script/dart_debugger.cc

Issue 1107803002: Add Observatory to sky dart_controller (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "dart/runtime/include/dart_api.h" 7 #include "dart/runtime/include/dart_api.h"
8 #include "dart/runtime/include/dart_debugger_api.h" 8 #include "dart/runtime/include/dart_debugger_api.h"
9 #include "dart/runtime/include/dart_native_api.h" 9 #include "dart/runtime/include/dart_native_api.h"
10 #include "mojo/dart/embedder/dart_debugger.h" 10 #include "dart_debugger.h"
11 11
12 namespace mojo { 12 namespace blink {
13 namespace dart {
14 13
15 void DartDebuggerIsolate::MessageLoop() { 14 void DartDebuggerIsolate::MessageLoop() {
16 MonitorLocker ml(&monitor_); 15 MonitorLocker ml(&monitor_);
17 // Request notification on isolate messages. This allows us to 16 // Request notification on isolate messages. This allows us to
18 // respond to vm service messages while at breakpoint. 17 // respond to vm service messages while at breakpoint.
19 Dart_SetMessageNotifyCallback(DartDebugger::NotifyIsolate); 18 Dart_SetMessageNotifyCallback(DartDebugger::NotifyIsolate);
20 while (true) { 19 while (true) {
21 // Handle all available vm service messages, up to a resume 20 // Handle all available vm service messages, up to a resume
22 // request. 21 // request.
23 bool resume = false; 22 bool resume = false;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 debugger_isolate->Notify(); 90 debugger_isolate->Notify();
92 } 91 }
93 } 92 }
94 93
95 void DartDebugger::InitDebugger() { 94 void DartDebugger::InitDebugger() {
96 Dart_SetIsolateEventHandler(IsolateEventHandler); 95 Dart_SetIsolateEventHandler(IsolateEventHandler);
97 Dart_SetPausedEventHandler(PausedEventHandler); 96 Dart_SetPausedEventHandler(PausedEventHandler);
98 Dart_SetBreakpointResolvedHandler(BptResolvedHandler); 97 Dart_SetBreakpointResolvedHandler(BptResolvedHandler);
99 Dart_SetExceptionThrownHandler(ExceptionThrownHandler); 98 Dart_SetExceptionThrownHandler(ExceptionThrownHandler);
100 lock_ = new base::Lock(); 99 lock_ = new base::Lock();
100 isolates_ = new std::vector<DartDebuggerIsolate*>();
101 } 101 }
102 102
103 DartDebuggerIsolate* DartDebugger::FindIsolateById(Dart_IsolateId id) { 103 DartDebuggerIsolate* DartDebugger::FindIsolateById(Dart_IsolateId id) {
104 base::AutoLock al(*lock_); 104 base::AutoLock al(*lock_);
105 return FindIsolateByIdLocked(id); 105 return FindIsolateByIdLocked(id);
106 } 106 }
107 107
108 DartDebuggerIsolate* DartDebugger::FindIsolateByIdLocked( 108 DartDebuggerIsolate* DartDebugger::FindIsolateByIdLocked(
109 Dart_IsolateId id) { 109 Dart_IsolateId id) {
110 lock_->AssertAcquired(); 110 lock_->AssertAcquired();
111 for (size_t i = 0; i < isolates_.size(); i++) { 111 for (size_t i = 0; i < isolates_->size(); i++) {
112 DartDebuggerIsolate* isolate = isolates_[i]; 112 DartDebuggerIsolate* isolate = (*isolates_)[i];
113 if (id == isolate->id()) { 113 if (id == isolate->id()) {
114 return isolate; 114 return isolate;
115 } 115 }
116 } 116 }
117 return nullptr; 117 return nullptr;
118 } 118 }
119 119
120 DartDebuggerIsolate* DartDebugger::AddIsolate(Dart_IsolateId id) { 120 DartDebuggerIsolate* DartDebugger::AddIsolate(Dart_IsolateId id) {
121 base::AutoLock al(*lock_); 121 base::AutoLock al(*lock_);
122 CHECK(FindIsolateByIdLocked(id) == nullptr); 122 CHECK(FindIsolateByIdLocked(id) == nullptr);
123 DartDebuggerIsolate* debugger_isolate = 123 DartDebuggerIsolate* debugger_isolate =
124 new DartDebuggerIsolate(id); 124 new DartDebuggerIsolate(id);
125 isolates_.push_back(debugger_isolate); 125 isolates_->push_back(debugger_isolate);
126 return debugger_isolate; 126 return debugger_isolate;
127 } 127 }
128 128
129 void DartDebugger::RemoveIsolate(Dart_IsolateId id) { 129 void DartDebugger::RemoveIsolate(Dart_IsolateId id) {
130 base::AutoLock al(*lock_); 130 base::AutoLock al(*lock_);
131 for (size_t i = 0; i < isolates_.size(); i++) { 131 for (size_t i = 0; i < isolates_->size(); i++) {
132 DartDebuggerIsolate* isolate = isolates_[i]; 132 DartDebuggerIsolate* isolate = (*isolates_)[i];
133 if (id == isolate->id()) { 133 if (id == isolate->id()) {
134 isolates_.erase(isolates_.begin() + i); 134 isolates_->erase(isolates_->begin() + i);
135 delete isolate;
135 return; 136 return;
136 } 137 }
137 } 138 }
138 NOTREACHED(); 139 NOTREACHED();
139 } 140 }
140 141
141 base::Lock* DartDebugger::lock_ = nullptr; 142 base::Lock* DartDebugger::lock_ = nullptr;
142 std::vector<DartDebuggerIsolate*> DartDebugger::isolates_; 143 std::vector<DartDebuggerIsolate*>* DartDebugger::isolates_ = nullptr;
143 144
144 } // namespace apps 145 } // namespace blink
145 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698