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

Unified Diff: chrome/browser/loader/safe_browsing_resource_throttle.cc

Issue 2616653002: Have a list of pending checks instead of pending clients (Closed)
Patch Set: rebase Created 3 years, 11 months 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: chrome/browser/loader/safe_browsing_resource_throttle.cc
diff --git a/chrome/browser/loader/safe_browsing_resource_throttle.cc b/chrome/browser/loader/safe_browsing_resource_throttle.cc
index 8fccf4b69c4e8e2b48cc580cdb8751c89e2cab7b..7b61854bfc50a720d561980f2de1fbcbbf075683 100644
--- a/chrome/browser/loader/safe_browsing_resource_throttle.cc
+++ b/chrome/browser/loader/safe_browsing_resource_throttle.cc
@@ -238,9 +238,10 @@ void SafeBrowsingResourceThrottle::OnCheckBrowseUrlResult(
CHECK(url.is_valid());
CHECK(url_being_checked_.is_valid());
if (url != url_being_checked_) {
- char buf[2000];
- snprintf(buf, sizeof(buf), "sbtr::ocbur:%s -- %s\n", url.spec().c_str(),
- url_being_checked_.spec().c_str());
+ bool url_had_timed_out = base::ContainsValue(timed_out_urls_, url);
+ char buf[1000];
+ snprintf(buf, sizeof(buf), "sbtr::ocbur:%d:%s -- %s\n", url_had_timed_out,
+ url.spec().c_str(), url_being_checked_.spec().c_str());
base::debug::Alias(buf);
CHECK(false) << "buf: " << buf;
}
@@ -398,11 +399,16 @@ bool SafeBrowsingResourceThrottle::CheckUrl(const GURL& url) {
BeginNetLogEvent(NetLogEventType::SAFE_BROWSING_CHECKING_URL, url, nullptr,
nullptr);
+ // If the URL had timed out earlier but is being retried, remove it from the
+ // list of URLs that timed out.
+ auto iter = std::find(timed_out_urls_.begin(), timed_out_urls_.end(), url);
+ if (iter != timed_out_urls_.end()) {
Nathan Parker 2017/01/06 01:41:01 same comment I had before: I don't think a URL can
vakh (use Gerrit instead) 2017/01/06 02:15:08 There you go! I agree that caring for SB check tim
+ timed_out_urls_.erase(iter);
+ }
// Start a timer to abort the check if it takes too long.
// TODO(nparker): Set this only when we defer, based on remaining time,
// so we don't cancel earlier than necessary.
- timer_.Start(FROM_HERE,
- base::TimeDelta::FromMilliseconds(kCheckUrlTimeoutMs),
+ timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kCheckUrlTimeoutMs),
this, &SafeBrowsingResourceThrottle::OnCheckUrlTimeout);
return false;
@@ -415,6 +421,7 @@ void SafeBrowsingResourceThrottle::OnCheckUrlTimeout() {
OnCheckBrowseUrlResult(url_being_checked_, safe_browsing::SB_THREAT_TYPE_SAFE,
safe_browsing::ThreatMetadata());
+ timed_out_urls_.push_back(url_being_checked_);
}
void SafeBrowsingResourceThrottle::ResumeRequest() {

Powered by Google App Engine
This is Rietveld 408576698