[Tracing w/SDK] Remove TraceStateObserver usage in Perfetto SDK build
Using TraceStateObserver when tracing is controlled by Perfetto can lead to inconsistencies. This CL removes its implementation. See crrev.com/c/4062038 for the V8 side change. Bug: 1006766 Change-Id: I1bccc1d61b518c851f23204147704ea0b23f2760 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4066184 Reviewed-by: Camillo Bruni <cbruni@chromium.org> Commit-Queue: Mikhail Khokhlov <khokhlov@google.com> Cr-Commit-Position: refs/heads/main@{#1077985}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
081983b0eb
commit
86a3c1d76c
@ -65,6 +65,7 @@ class ConvertableToTraceFormatWrapper final
|
||||
std::unique_ptr<v8::ConvertableToTraceFormat> inner_;
|
||||
};
|
||||
|
||||
#if !BUILDFLAG(USE_PERFETTO_CLIENT_LIBRARY)
|
||||
class EnabledStateObserverImpl final
|
||||
: public base::trace_event::TraceLog::EnabledStateObserver {
|
||||
public:
|
||||
@ -120,6 +121,7 @@ class EnabledStateObserverImpl final
|
||||
|
||||
base::LazyInstance<EnabledStateObserverImpl>::Leaky g_trace_state_dispatcher =
|
||||
LAZY_INSTANCE_INITIALIZER;
|
||||
#endif // !BUILDFLAG(USE_PERFETTO_CLIENT_LIBRARY)
|
||||
|
||||
// TODO(skyostil): Deduplicate this with the clamper in Blink.
|
||||
class TimeClamper {
|
||||
@ -347,13 +349,13 @@ class V8Platform::TracingControllerImpl : public v8::TracingController {
|
||||
TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_enabled_flag, name,
|
||||
traceEventHandle);
|
||||
}
|
||||
#endif // !BUILDFLAG(USE_PERFETTO_CLIENT_LIBRARY)
|
||||
void AddTraceStateObserver(TraceStateObserver* observer) override {
|
||||
g_trace_state_dispatcher.Get().AddObserver(observer);
|
||||
}
|
||||
void RemoveTraceStateObserver(TraceStateObserver* observer) override {
|
||||
g_trace_state_dispatcher.Get().RemoveObserver(observer);
|
||||
}
|
||||
#endif // !BUILDFLAG(USE_PERFETTO_CLIENT_LIBRARY)
|
||||
};
|
||||
|
||||
// static
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "base/trace_event/trace_event.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
#if !BUILDFLAG(USE_PERFETTO_CLIENT_LIBRARY)
|
||||
class TestTraceStateObserver
|
||||
: public v8::TracingController::TraceStateObserver {
|
||||
public:
|
||||
@ -26,9 +27,12 @@ class TestTraceStateObserver
|
||||
int enabled_ = 0;
|
||||
int disabled_ = 0;
|
||||
};
|
||||
#endif // !BUILDFLAG(USE_PERFETTO_CLIENT_LIBRARY)
|
||||
|
||||
namespace gin {
|
||||
|
||||
// No TraceStateObservers in Perfetto build.
|
||||
#if !BUILDFLAG(USE_PERFETTO_CLIENT_LIBRARY)
|
||||
TEST(V8PlatformTest, TraceStateObserverAPI) {
|
||||
TestTraceStateObserver test_observer;
|
||||
ASSERT_EQ(0, test_observer.Enabled());
|
||||
@ -70,6 +74,7 @@ TEST(V8PlatformTest, TraceStateObserverFired) {
|
||||
V8Platform::Get()->GetTracingController()->RemoveTraceStateObserver(
|
||||
&test_observer);
|
||||
}
|
||||
#endif // !BUILDFLAG(USE_PERFETTO_CLIENT_LIBRARY)
|
||||
|
||||
// Tests that PostJob runs a task and is done after Join.
|
||||
TEST(V8PlatformTest, PostJobSimple) {
|
||||
|
Reference in New Issue
Block a user