There is a deliberate race condition in metrics setup, between the Java and native side, since both do asynchronous work. In Java, AwBrowserProcess.handleMinidumpsAndSetMetricsConsent asynchronously queries GMS, and passes the result to AwMetricsServiceClient.setConsentSetting. In native, AwMetricsServiceClient::Initialize asynchronously reads the GUID, then passes the result to AwMetricsServiceClient::InitializeWithGUID. Either path may finish first, and AwMetricsServiceClient.java is written to handle this race condition.
But with the Finch project, the GUID read is being made synchronous. If the entire code path from WebViewChromiumFactoryProvider to AwMetricsServiceClient::Initialize is synchronous (and we can rely on it remaining that way in the future) then it's impossible for the GMS callback (which happens on the UI thread) to fire before AwMetricsServiceClient initialization. Then there is no race condition, and we can simplify the logic in AwMetricsServiceClient.java.
Comment 1 by sgu...@chromium.org
, Sep 27 2017