Remove dependency from VM isolate name convention (flutter/engine#4007)

Dart_DebugName should be used just to make debug outputs more readable.

We remove the dependency from this API and form the UIDartState debug
name in the engine using the predefined format:
<script_uri>$main-<main_port>

This will allow the engine to change the format of the isolate name
without breaking the engine.
Related https://codereview.chromium.org/3004563003/
This commit is contained in:
Carlo Bernaschina
2017-08-25 11:11:52 -07:00
committed by GitHub
parent 6a41695e04
commit f3aaa23f74
3 changed files with 12 additions and 5 deletions

View File

@@ -34,12 +34,11 @@ UIDartState* UIDartState::CreateForChildIsolate() {
}
void UIDartState::DidSetIsolate() {
FTL_DCHECK(!debug_name_prefix_.empty());
main_port_ = Dart_GetMainPortId();
tonic::DartApiScope api_scope;
Dart_Handle debug_name = Dart_DebugName();
if (Dart_IsString(debug_name)) {
debug_name_ = tonic::StdStringFromDart(debug_name);
}
std::ostringstream debug_name;
debug_name << debug_name_prefix_ << "$main-" << main_port_;
debug_name_ = debug_name.str();
}
UIDartState* UIDartState::Current() {
@@ -50,8 +49,13 @@ void UIDartState::set_font_selector(PassRefPtr<FontSelector> selector) {
font_selector_ = selector;
}
PassRefPtr<FontSelector> UIDartState::font_selector() {
return font_selector_;
}
void UIDartState::set_debug_name_prefix(const std::string& debug_name_prefix) {
debug_name_prefix_ = debug_name_prefix;
}
} // namespace blink

View File

@@ -39,6 +39,7 @@ class UIDartState : public tonic::DartState {
const std::string& debug_name() const { return debug_name_; }
Window* window() const { return window_.get(); }
void set_debug_name_prefix(const std::string& debug_name_prefix);
void set_font_selector(PassRefPtr<FontSelector> selector);
PassRefPtr<FontSelector> font_selector();
@@ -47,6 +48,7 @@ class UIDartState : public tonic::DartState {
IsolateClient* isolate_client_;
Dart_Port main_port_;
std::string debug_name_prefix_;
std::string debug_name_;
std::unique_ptr<Window> window_;
RefPtr<FontSelector> font_selector_;

View File

@@ -196,6 +196,7 @@ void DartController::CreateIsolateFor(const std::string& script_uri,
Dart_SetShouldPauseOnStart(Settings::Get().start_paused);
ui_dart_state_->set_debug_name_prefix(script_uri);
ui_dart_state_->SetIsolate(isolate);
FTL_CHECK(!LogIfError(
Dart_SetLibraryTagHandler(tonic::DartState::HandleLibraryTag)));