[LCP] Check tracing enabled before tracing

Currently TextPaintTimingDetector and ImagePaintTimingDetector dumps a
trace event whenever it finds a new candidate. However, the event won't
not be generated when the "loading" category is disabled. When we have
any preparation cost for the trace event, the cost would be wasted in
this case.

For this reason, we add a check in this change. We check whether the
event category is enabled before preparing the trace value.

In addition, we whitelist trace_event_analyzer.cc for blink tests
so that we can test the code path of enabling/disabling the trace
category.

Bug:976894,978475

Change-Id: Ibca63be435f7f96b2bad64fa3aaffe2df8ba232e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1676230
Reviewed-by: Liquan (Max) Gu <maxlg@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672258}
6 files changed