Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Unified Diff: components/safe_browsing_db/v4_update_protocol_manager.cc

Issue 2470923003: Handle timeout for update requests. (Closed)
Patch Set: Added a histogram for counting update timeouts Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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(

Powered by Google App Engine
This is Rietveld 408576698