Almost remove //flutter/tonic (flutter/engine#2916)

All that's left is two task runners, which should be statics somewhere.
This commit is contained in:
Adam Barth
2016-08-12 09:42:32 -07:00
committed by GitHub
parent 37652cc041
commit cbb28cb25d
9 changed files with 21 additions and 218 deletions

2
DEPS
View File

@@ -55,7 +55,7 @@ deps = {
Var('fuchsia_git') + '/ftl' + '@' + '0bb3a02301c8a88b494e58c6636fa509525adaa8',
'src/lib/tonic':
Var('fuchsia_git') + '/tonic' + '@' + '66fc8a71ae54c628537e7f4b2e8bf9304788c19d',
Var('fuchsia_git') + '/tonic' + '@' + 'e559b5fab4bad0fb528c68497a02df280f526c66',
'src/third_party/gtest':
Var('fuchsia_git') + '/third_party/gtest' + '@' + 'c00f82917331efbbd27124b537e4ccc915a02b72',

View File

@@ -0,0 +1,17 @@
# Copyright 2016 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.
source_set("io") {
sources = [
"dart_io.cc",
"dart_io.h",
]
deps = [
"//dart/runtime:libdart",
"//dart/runtime/bin:embedded_dart_io",
"//lib/ftl",
"//lib/tonic/converter",
]
}

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/tonic/dart_io.h"
#include "flutter/lib/io/dart_io.h"
#include "dart/runtime/bin/io_natives.h"
#include "dart/runtime/include/dart_api.h"

View File

@@ -46,5 +46,6 @@ source_set("ui") {
"//flutter/skia",
"//flutter/tonic",
"//lib/tonic",
"//lib/tonic/mojo",
]
}

View File

@@ -14,7 +14,7 @@
#include "lib/ftl/tasks/task_runner.h"
#include "lib/tonic/dart_persistent_value.h"
#include "lib/tonic/logging/dart_invoke.h"
#include "lib/tonic/mojo_converter.h"
#include "lib/tonic/mojo/mojo_converter.h"
#include "lib/tonic/typed_data/uint8_list.h"
#include "third_party/skia/include/core/SkImageGenerator.h"

View File

@@ -4,10 +4,6 @@
source_set("tonic") {
sources = [
"dart_debugger.cc",
"dart_debugger.h",
"dart_io.cc",
"dart_io.h",
"dart_state.cc",
"dart_state.h",
]

View File

@@ -1,139 +0,0 @@
// 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.
#include "flutter/tonic/dart_debugger.h"
#include "dart/runtime/include/dart_api.h"
#include "dart/runtime/include/dart_native_api.h"
#include "dart/runtime/include/dart_tools_api.h"
#include "lib/ftl/logging.h"
namespace blink {
void DartDebuggerIsolate::MessageLoop() {
ftl::MonitorLocker locker(&monitor_);
Dart_MessageNotifyCallback saved_message_notify_callback =
Dart_GetMessageNotifyCallback();
// Request notification on isolate messages. This allows us to
// respond to vm service messages while at breakpoint.
Dart_SetMessageNotifyCallback(DartDebugger::NotifyIsolate);
while (true) {
// Handle all available vm service messages, up to a resume
// request.
bool resume = false;
while (!resume && Dart_HasServiceMessages()) {
monitor_.Exit();
resume = Dart_HandleServiceMessages();
monitor_.Enter();
}
if (resume) {
break;
}
locker.Wait();
}
Dart_SetMessageNotifyCallback(saved_message_notify_callback);
}
void DartDebugger::BptResolvedHandler(Dart_IsolateId isolate_id,
intptr_t bp_id,
const Dart_CodeLocation& location) {
// Nothing to do here. Service event is dispatched to let Observatory know
// that a breakpoint was resolved.
}
void DartDebugger::PausedEventHandler(Dart_IsolateId isolate_id,
intptr_t bp_id,
const Dart_CodeLocation& loc) {
Dart_EnterScope();
intptr_t isolate_index = FindIsolateIndexById(isolate_id);
FTL_CHECK(isolate_index != -1);
(*isolates_)[isolate_index]->MessageLoop();
Dart_ExitScope();
}
void DartDebugger::ExceptionThrownHandler(Dart_IsolateId isolate_id,
Dart_Handle exception,
Dart_StackTrace stack_trace) {
Dart_EnterScope();
intptr_t isolate_index = FindIsolateIndexById(isolate_id);
FTL_CHECK(isolate_index != -1);
(*isolates_)[isolate_index]->MessageLoop();
Dart_ExitScope();
}
void DartDebugger::IsolateEventHandler(Dart_IsolateId isolate_id,
Dart_IsolateEvent kind) {
Dart_EnterScope();
if (kind == Dart_IsolateEvent::kCreated) {
AddIsolate(isolate_id);
} else {
intptr_t isolate_index = FindIsolateIndexById(isolate_id);
FTL_CHECK(isolate_index != -1);
if (kind == Dart_IsolateEvent::kInterrupted) {
(*isolates_)[isolate_index]->MessageLoop();
} else {
FTL_CHECK(kind == Dart_IsolateEvent::kShutdown);
RemoveIsolate(isolate_id);
}
}
Dart_ExitScope();
}
void DartDebugger::NotifyIsolate(Dart_Isolate isolate) {
ftl::MutexLocker locker(mutex_);
Dart_IsolateId isolate_id = Dart_GetIsolateId(isolate);
intptr_t isolate_index = FindIsolateIndexByIdLocked(isolate_id);
if (isolate_index >= 0) {
(*isolates_)[isolate_index]->Notify();
}
}
void DartDebugger::InitDebugger() {
Dart_SetIsolateEventHandler(IsolateEventHandler);
Dart_SetPausedEventHandler(PausedEventHandler);
Dart_SetBreakpointResolvedHandler(BptResolvedHandler);
Dart_SetExceptionThrownHandler(ExceptionThrownHandler);
mutex_ = new ftl::Mutex();
isolates_ = new std::vector<std::unique_ptr<DartDebuggerIsolate>>();
}
intptr_t DartDebugger::FindIsolateIndexById(Dart_IsolateId id) {
ftl::MutexLocker locker(mutex_);
return FindIsolateIndexByIdLocked(id);
}
intptr_t DartDebugger::FindIsolateIndexByIdLocked(Dart_IsolateId id) {
mutex_->AssertHeld();
for (size_t i = 0; i < isolates_->size(); i++) {
if ((*isolates_)[i]->id() == id) {
return i;
}
}
return -1;
}
void DartDebugger::AddIsolate(Dart_IsolateId id) {
ftl::MutexLocker locker(mutex_);
FTL_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) {
ftl::MutexLocker locker(mutex_);
for (size_t i = 0; i < isolates_->size(); i++) {
if (id == (*isolates_)[i]->id()) {
isolates_->erase(isolates_->begin() + i);
return;
}
}
FTL_NOTREACHED();
}
ftl::Mutex* DartDebugger::mutex_ = nullptr;
std::vector<std::unique_ptr<DartDebuggerIsolate>>* DartDebugger::isolates_ =
nullptr;
} // namespace blink

View File

@@ -1,72 +0,0 @@
// 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 FLUTTER_TONIC_DART_DEBUGGER_H_
#define FLUTTER_TONIC_DART_DEBUGGER_H_
#include <memory>
#include <vector>
#include "dart/runtime/include/dart_api.h"
#include "dart/runtime/include/dart_native_api.h"
#include "dart/runtime/include/dart_tools_api.h"
#include "lib/ftl/synchronization/monitor.h"
#include "lib/ftl/synchronization/mutex.h"
namespace blink {
class DartDebuggerIsolate {
public:
DartDebuggerIsolate(Dart_IsolateId id) : id_(id) {}
Dart_IsolateId id() const { return id_; }
void Notify() { monitor_.Signal(); }
void MessageLoop();
private:
const Dart_IsolateId id_;
ftl::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 intptr_t FindIsolateIndexById(Dart_IsolateId id);
static intptr_t FindIsolateIndexByIdLocked(Dart_IsolateId id);
static void AddIsolate(Dart_IsolateId id);
static void RemoveIsolate(Dart_IsolateId id);
static ftl::Mutex* mutex_;
static std::vector<std::unique_ptr<DartDebuggerIsolate>>* isolates_;
friend class DartDebuggerIsolate;
};
} // namespace blink
#endif // FLUTTER_TONIC_DART_DEBUGGER_H_