Split the wait-for-result part and push-result-to-doc part.

Change-Id: I496fa9274922603f4c7efdcab90e66a23df741fa