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

Unified Diff: components/safe_browsing_db/v4_update_protocol_manager.cc

Issue 2470923003: Handle timeout for update requests. (Closed)
Patch Set: 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 ae43b2e3b404fcbc3fd97af82a2cb15a0b1f9dc6..1098f7f09c0a0873be2acb8754dc36f7c5ed8d85 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 {
@@ -250,7 +253,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()) {
@@ -295,7 +297,16 @@ 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() {
+ request_.reset();
Nathan Parker 2016/11/02 21:56:57 This should log some UMA value to indicate the req
vakh (use Gerrit instead) 2016/11/02 22:37:22 I thought about it but I couldn't find a good way
Nathan Parker 2016/11/05 00:32:21 Yes, you can use a UMA_HISTOGRAM just as a counter
+ IssueUpdateRequest();
Nathan Parker 2016/11/02 21:56:57 This will keep trying every 30 seconds. Is that wh
Scott Hess - ex-Googler 2016/11/02 22:05:08 Does the spec address this? I see language about
vakh (use Gerrit instead) 2016/11/02 22:37:22 Sure, that's possible. But what happens after that
vakh (use Gerrit instead) 2016/11/02 22:37:22 No, I don't see it: https://developers.google.com/
vakh (use Gerrit instead) 2016/11/08 17:51:40 Changed the code to schedule a normal update after
}
// net::URLFetcherDelegate implementation ----------------------------------
@@ -305,6 +316,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