Chromium Code Reviews| Index: components/safe_browsing_db/v4_update_protocol_manager.cc |
| diff --git a/components/safe_browsing_db/v4_update_protocol_manager.cc b/components/safe_browsing_db/v4_update_protocol_manager.cc |
| index 070f4438b580992b2a4a7ebef36eb2d816180be1..b1d468db77fa32d0ecae9f3ee9365747c1877b8e 100644 |
| --- a/components/safe_browsing_db/v4_update_protocol_manager.cc |
| +++ b/components/safe_browsing_db/v4_update_protocol_manager.cc |
| @@ -70,6 +70,9 @@ static const int kV4TimerStartIntervalSecMin = 60; |
| // Maximum time, in seconds, from start up before we must issue an update query. |
| static const int kV4TimerStartIntervalSecMax = 300; |
| +// Maximum time, in seconds, to wait for a response to an update request. |
| +static const int kV4TimerUpdateWaitSecMax = 30; |
| + |
| // The default V4UpdateProtocolManagerFactory. |
| class V4UpdateProtocolManagerFactoryImpl |
| : public V4UpdateProtocolManagerFactory { |
| @@ -248,7 +251,6 @@ bool V4UpdateProtocolManager::ParseUpdateResponse( |
| base::TimeDelta::FromSeconds(minimum_wait_duration_seconds); |
| } |
| - // TODO(vakh): Do something useful with this response. |
| for (ListUpdateResponse& list_update_response : |
| *response.mutable_list_update_responses()) { |
| if (!list_update_response.has_platform_type()) { |
| @@ -293,7 +295,17 @@ void V4UpdateProtocolManager::IssueUpdateRequest() { |
| request_->SetLoadFlags(net::LOAD_DISABLE_CACHE); |
| request_->SetRequestContext(request_context_getter_.get()); |
| request_->Start(); |
| - // TODO(vakh): Handle request timeout. |
| + |
| + // Begin the update request timeout. |
| + timeout_timer_.Start(FROM_HERE, |
| + TimeDelta::FromSeconds(kV4TimerUpdateWaitSecMax), this, |
| + &V4UpdateProtocolManager::HandleTimeout); |
| +} |
| + |
| +void V4UpdateProtocolManager::HandleTimeout() { |
| + UMA_HISTOGRAM_COUNTS_100("SafeBrowsing.V4Update.Timeout.Count", 1); |
|
Nathan Parker
2016/11/08 23:39:29
Or UMA_HISTOGRAM_BOOLEAN("..", true)
either way
vakh (use Gerrit instead)
2016/11/09 00:08:51
Done.
|
| + request_.reset(); |
| + ScheduleNextUpdateWithBackoff(false); |
| } |
| // net::URLFetcherDelegate implementation ---------------------------------- |
| @@ -303,6 +315,8 @@ void V4UpdateProtocolManager::OnURLFetchComplete( |
| const net::URLFetcher* source) { |
| DCHECK(CalledOnValidThread()); |
| + timeout_timer_.Stop(); |
| + |
| int response_code = source->GetResponseCode(); |
| net::URLRequestStatus status = source->GetStatus(); |
| V4ProtocolManagerUtil::RecordHttpResponseOrErrorCode( |