mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
* Name the platform thread in the timeline. This does not affect (nor is it affected by) the pthread name set by the embedder. * Make it easier in the timeline to see not only when the frame was request, but also when that frame request was fulfilled. * Trace message loop wakes.
52 lines
1.5 KiB
C++
52 lines
1.5 KiB
C++
// 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/shell/common/tracing_controller.h"
|
|
|
|
#include <string>
|
|
|
|
#include "dart/runtime/include/dart_tools_api.h"
|
|
#include "flutter/common/threads.h"
|
|
#include "flutter/fml/trace_event.h"
|
|
#include "flutter/runtime/dart_init.h"
|
|
#include "flutter/shell/common/shell.h"
|
|
#include "lib/ftl/logging.h"
|
|
|
|
namespace shell {
|
|
|
|
TracingController::TracingController() : tracing_active_(false) {
|
|
blink::SetEmbedderTracingCallbacks(
|
|
std::unique_ptr<blink::EmbedderTracingCallbacks>(
|
|
new blink::EmbedderTracingCallbacks([this]() { StartTracing(); },
|
|
[this]() { StopTracing(); })));
|
|
}
|
|
|
|
TracingController::~TracingController() {
|
|
blink::SetEmbedderTracingCallbacks(nullptr);
|
|
}
|
|
|
|
static void AddTraceMetadata() {
|
|
blink::Threads::Gpu()->PostTask([]() { Dart_SetThreadName("gpu_thread"); });
|
|
blink::Threads::UI()->PostTask([]() { Dart_SetThreadName("ui_thread"); });
|
|
blink::Threads::IO()->PostTask([]() { Dart_SetThreadName("io_thread"); });
|
|
blink::Threads::Platform()->PostTask(
|
|
[]() { Dart_SetThreadName("platform_thread"); });
|
|
}
|
|
|
|
void TracingController::StartTracing() {
|
|
if (tracing_active_)
|
|
return;
|
|
tracing_active_ = true;
|
|
AddTraceMetadata();
|
|
}
|
|
|
|
void TracingController::StopTracing() {
|
|
if (!tracing_active_) {
|
|
return;
|
|
}
|
|
tracing_active_ = false;
|
|
}
|
|
|
|
} // namespace shell
|