Chromium Code Reviews| Index: components/network_time/network_time_tracker.cc |
| diff --git a/components/network_time/network_time_tracker.cc b/components/network_time/network_time_tracker.cc |
| index dc4ccbb56d3f498294705195257f675a74afbcde..5be7d572fb1278eef929414f4839deff045e69fd 100644 |
| --- a/components/network_time/network_time_tracker.cc |
| +++ b/components/network_time/network_time_tracker.cc |
| @@ -13,6 +13,8 @@ |
| #include "base/json/json_reader.h" |
| #include "base/logging.h" |
| #include "base/message_loop/message_loop.h" |
| +#include "base/metrics/histogram_macros.h" |
| +#include "base/metrics/sparse_histogram.h" |
| #include "base/rand_util.h" |
| #include "base/run_loop.h" |
| #include "base/strings/string_number_conversions.h" |
| @@ -367,6 +369,9 @@ void NetworkTimeTracker::CheckTime() { |
| net::LOAD_DO_NOT_SAVE_COOKIES | |
| net::LOAD_DO_NOT_SEND_COOKIES | |
| net::LOAD_DO_NOT_SEND_AUTH_DATA); |
| + |
| + UMA_HISTOGRAM_BOOLEAN("NetworkTimeTracker.UpdateTimeFetchAttempted", true); |
|
mab
2016/07/26 21:05:48
Is a Boolean the idiomatic way to count things?
estark
2016/07/26 21:21:27
I have been told that it is, though admittedly I c
mab
2016/07/27 02:47:56
Ack.
|
| + |
| time_fetcher_->Start(); |
| fetch_started_ = tick_clock_->NowTicks(); |
| @@ -374,13 +379,17 @@ void NetworkTimeTracker::CheckTime() { |
| } |
| bool NetworkTimeTracker::UpdateTimeFromResponse() { |
| - if (time_fetcher_->GetStatus().status() != net::URLRequestStatus::SUCCESS && |
| + if (time_fetcher_->GetStatus().status() != net::URLRequestStatus::SUCCESS || |
|
mab
2016/07/26 21:05:48
Yikes, good catch.
mab
2016/07/28 06:58:54
(I take it your metrics would have caught this bug
estark
2016/07/28 18:27:58
Presumably, yeah -- one of the tests I added faile
|
| time_fetcher_->GetResponseCode() != 200) { |
| DVLOG(1) << "fetch failed, status=" << time_fetcher_->GetStatus().status() |
| << ",code=" << time_fetcher_->GetResponseCode(); |
| + UMA_HISTOGRAM_SPARSE_SLOWLY("NetworkTimeTracker.UpdateTimeFetchFailed", |
| + -time_fetcher_->GetStatus().error()); |
|
mab
2016/07/26 21:05:48
Why negative? Is that the convention for errors?
estark
2016/07/26 21:21:26
Net error codes are negative (see net/base/net_err
mab
2016/07/27 02:47:56
OK, SG.
|
| return false; |
| } |
| + UMA_HISTOGRAM_BOOLEAN("NetworkTimeTracker.UpdateTimeFetchSucceeded", true); |
|
mab
2016/07/26 21:05:48
I think you could get away with having just one hi
estark
2016/07/26 21:21:26
By "just one histogram", do you mean collapsing Up
mab
2016/07/27 02:47:56
I meant collapse all 4 into one. Is the problem t
estark
2016/07/27 17:50:56
Yeah, I don't know of any way to do that... but a
mab
2016/07/28 06:58:55
Sure. Can you document that intent somewhere outs
estark
2016/07/28 18:27:58
Filed https://crbug.com/632419
|
| + |
| std::string response_body; |
| if (!time_fetcher_->GetResponseAsString(&response_body)) { |
| DVLOG(1) << "failed to get response"; |
| @@ -408,6 +417,9 @@ bool NetworkTimeTracker::UpdateTimeFromResponse() { |
| DVLOG(1) << "no current_time_millis"; |
| return false; |
| } |
| + |
| + UMA_HISTOGRAM_BOOLEAN("NetworkTimeTracker.UpdateTimeFetchValid", true); |
| + |
| // There is a "server_nonce" key here too, but it serves no purpose other than |
| // to make the server's response unpredictable. |
| base::Time current_time = base::Time::FromJsTime(current_time_millis); |