Enhance RTCUIApplicationStatusObserver thread safety.

Add locking around waiting for initialization to finish, since calling
dispatch_block_wait from multiple threads leads to undefined behavior.

Initialize RTCUIApplicationStatusObserver earlier to give the
initialization block more time to run on the main thread before
starting to query the application state.

http://www.dailymotion.com/video/x2mckmh

BUG=b/65558688

Review-Url: https://codereview.webrtc.org/3009383002
Cr-Original-Commit-Position: refs/heads/master@{#19822}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 9a85f0782ea4647d77515b48b4bd2e1b0826210a
4 files changed