client: Add the client-side metrics.

This patch collects and reports the following metrics when
--get-url is used:
 * P2P.Client.LookupResult
 * P2P.Client.NumPeers
 * P2P.Client.Found.WaitingTimeSeconds
 * P2P.Client.Found.ConnectionCount
 * P2P.Client.Found.CandidateCount
 * P2P.Client.Vanished.WaitingTimeSeconds
 * P2P.Client.Canceled.WaitingTimeSeconds

In order to report the LookupResult "Filtered", a new method is added
to the ServiceFinder interface.

On the other hand, whenever the program receives a SIGTERM it is
handled in a way that all the blocking functions return and the
collected metrics are sent back. This is used by P2P consumers to
cancel a --get-url call that is taking too long.

BUG=chromium:260485,chromium:267082
TEST=unittests ;-) and manually verified via chrome://histograms in few cases.
Also tested that a SIGTERM during avahi lookup sends the Canceled metrics.

Change-Id: I6c39db7c99341934d7bc71dd0ddf222569172b22
Reviewed-on: https://gerrit.chromium.org/gerrit/64306
Commit-Queue: Alex Deymo <deymo@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
13 files changed