Flush event timings at visibility change

This is to ensure that event timing data are emitted to performance
timeline and recorded in the UKM and trace when document unloading happens.

We choose the page visibility change time point to report event
timings.

Current implementation works for main frame.

See https://docs.google.com/document/d/1aJcnDSgbKbY_SHDc5FHK4o_PcV8p5C9CS6cmD048DgQ/edit?usp=sharing
for details.

Change-Id: Ied9673a1be54f4ef5e0fdaf97244f96b69aecb33
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5502651
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: Michal Mocny <mmocny@chromium.org>
Reviewed-by: Aoyuan Zuo <zuoaoyuan@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Commit-Queue: Hao Liu <haoliuk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1326363}
NOKEYCHECK=True
GitOrigin-RevId: e317b68be16b5774b22e4561c94aefbafd30793c
1 file changed