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

Side by Side Diff: chrome/browser/loader/safe_browsing_resource_throttle.cc

Issue 2616653002: Have a list of pending checks instead of pending clients (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/loader/safe_browsing_resource_throttle.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/loader/safe_browsing_resource_throttle.h" 5 #include "chrome/browser/loader/safe_browsing_resource_throttle.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/debug/alias.h" 10 #include "base/debug/alias.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 void SafeBrowsingResourceThrottle::OnCheckBrowseUrlResult( 231 void SafeBrowsingResourceThrottle::OnCheckBrowseUrlResult(
232 const GURL& url, 232 const GURL& url,
233 safe_browsing::SBThreatType threat_type, 233 safe_browsing::SBThreatType threat_type,
234 const safe_browsing::ThreatMetadata& metadata) { 234 const safe_browsing::ThreatMetadata& metadata) {
235 CHECK_EQ(state_, STATE_CHECKING_URL); 235 CHECK_EQ(state_, STATE_CHECKING_URL);
236 // TODO(vakh): The following base::debug::Alias() and CHECK calls should be 236 // TODO(vakh): The following base::debug::Alias() and CHECK calls should be
237 // removed after http://crbug.com/660293 is fixed. 237 // removed after http://crbug.com/660293 is fixed.
238 CHECK(url.is_valid()); 238 CHECK(url.is_valid());
239 CHECK(url_being_checked_.is_valid()); 239 CHECK(url_being_checked_.is_valid());
240 if (url != url_being_checked_) { 240 if (url != url_being_checked_) {
241 char buf[2000]; 241 bool url_had_timed_out = base::ContainsValue(timed_out_urls_, url);
Nathan Parker 2017/01/04 18:48:18 A thought: If this disproves the theory, we might
vakh (use Gerrit instead) 2017/01/06 00:31:14 With the recent findings that I posted on http://c
242 snprintf(buf, sizeof(buf), "sbtr::ocbur:%s -- %s\n", url.spec().c_str(), 242 char buf[1000];
Scott Hess - ex-Googler 2017/01/04 18:52:10 Most of the minidumps I see are ~5M, so reducing t
vakh (use Gerrit instead) 2017/01/06 00:31:14 Yes, but the buffer was too large and having the f
243 url_being_checked_.spec().c_str()); 243 snprintf(buf, sizeof(buf), "sbtr::ocbur:%d:%s -- %s\n", url_had_timed_out,
244 url.spec().c_str(), url_being_checked_.spec().c_str());
244 base::debug::Alias(buf); 245 base::debug::Alias(buf);
245 CHECK(false) << "buf: " << buf; 246 CHECK(false) << "buf: " << buf;
246 } 247 }
247 248
248 timer_.Stop(); // Cancel the timeout timer. 249 timer_.Stop(); // Cancel the timeout timer.
249 threat_type_ = threat_type; 250 threat_type_ = threat_type;
250 state_ = STATE_NONE; 251 state_ = STATE_NONE;
251 252
252 if (defer_state_ != DEFERRED_NONE) { 253 if (defer_state_ != DEFERRED_NONE) {
253 EndNetLogEvent(NetLogEventType::SAFE_BROWSING_DEFERRED, nullptr, nullptr); 254 EndNetLogEvent(NetLogEventType::SAFE_BROWSING_DEFERRED, nullptr, nullptr);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 threat_type_ = safe_browsing::SB_THREAT_TYPE_SAFE; 392 threat_type_ = safe_browsing::SB_THREAT_TYPE_SAFE;
392 ui_manager_->LogPauseDelay(base::TimeDelta()); // No delay. 393 ui_manager_->LogPauseDelay(base::TimeDelta()); // No delay.
393 return true; 394 return true;
394 } 395 }
395 396
396 state_ = STATE_CHECKING_URL; 397 state_ = STATE_CHECKING_URL;
397 url_being_checked_ = url; 398 url_being_checked_ = url;
398 BeginNetLogEvent(NetLogEventType::SAFE_BROWSING_CHECKING_URL, url, nullptr, 399 BeginNetLogEvent(NetLogEventType::SAFE_BROWSING_CHECKING_URL, url, nullptr,
399 nullptr); 400 nullptr);
400 401
402 // If the URL had timed out earlier but is being retried, remove it from the
Nathan Parker 2017/01/04 18:48:18 I don't think they can get retried.
vakh (use Gerrit instead) 2017/01/06 00:31:14 Quite possibly, but I don't understand the SBRT's
403 // list of URLs that timed out.
404 auto iter = std::find(timed_out_urls_.begin(), timed_out_urls_.end(), url);
405 if (iter != timed_out_urls_.end()) {
406 timed_out_urls_.erase(iter);
407 }
Scott Hess - ex-Googler 2017/01/04 18:52:10 timed_out_urls_.erase(std::remove(timed_out_urls_.
vakh (use Gerrit instead) 2017/01/06 00:31:15 The STL version is so much harder understand, IMO.
Scott Hess - ex-Googler 2017/01/06 00:48:53 ACK on the erase(remove()) idiom, but what did you
vakh (use Gerrit instead) 2017/01/06 01:05:50 Sorry, I missed that. As far as I can tell, ordere
Scott Hess - ex-Googler 2017/01/06 02:42:27 I mean for timed_out_urls_. So that this code can
vakh (use Gerrit instead) 2017/01/06 02:46:59 Gah, I don't know why I am talking nonsense. You'r
Scott Hess - ex-Googler 2017/01/06 04:27:18 That's an even better solution!
Scott Hess - ex-Googler 2017/01/10 21:16:12 I took this thread to mean that you had removed th
vakh (use Gerrit instead) 2017/01/10 21:38:08 Changed to std::set but, frankly, I think it doesn
Scott Hess - ex-Googler 2017/01/10 21:43:05 Oh, I agree it doesn't matter. But assume the wor
401 // Start a timer to abort the check if it takes too long. 408 // Start a timer to abort the check if it takes too long.
402 // TODO(nparker): Set this only when we defer, based on remaining time, 409 // TODO(nparker): Set this only when we defer, based on remaining time,
403 // so we don't cancel earlier than necessary. 410 // so we don't cancel earlier than necessary.
404 timer_.Start(FROM_HERE, 411 timer_.Start(FROM_HERE,
405 base::TimeDelta::FromMilliseconds(kCheckUrlTimeoutMs), 412 base::TimeDelta::FromMilliseconds(kCheckUrlTimeoutMs),
406 this, &SafeBrowsingResourceThrottle::OnCheckUrlTimeout); 413 this, &SafeBrowsingResourceThrottle::OnCheckUrlTimeout);
407 414
408 return false; 415 return false;
409 } 416 }
410 417
411 void SafeBrowsingResourceThrottle::OnCheckUrlTimeout() { 418 void SafeBrowsingResourceThrottle::OnCheckUrlTimeout() {
412 CHECK_EQ(state_, STATE_CHECKING_URL); 419 CHECK_EQ(state_, STATE_CHECKING_URL);
413 420
414 database_manager_->CancelCheck(this); 421 database_manager_->CancelCheck(this);
415 422
416 OnCheckBrowseUrlResult(url_being_checked_, safe_browsing::SB_THREAT_TYPE_SAFE, 423 OnCheckBrowseUrlResult(url_being_checked_, safe_browsing::SB_THREAT_TYPE_SAFE,
417 safe_browsing::ThreatMetadata()); 424 safe_browsing::ThreatMetadata());
425 timed_out_urls_.push_back(url_being_checked_);
Nathan Parker 2017/01/04 18:48:18 nit: Would it work to just increment an timed_out_
vakh (use Gerrit instead) 2017/01/06 00:31:14 Not sure how that would work since we need to comp
418 } 426 }
419 427
420 void SafeBrowsingResourceThrottle::ResumeRequest() { 428 void SafeBrowsingResourceThrottle::ResumeRequest() {
421 CHECK_EQ(state_, STATE_NONE); 429 CHECK_EQ(state_, STATE_NONE);
422 CHECK_NE(defer_state_, DEFERRED_NONE); 430 CHECK_NE(defer_state_, DEFERRED_NONE);
423 431
424 bool resume = true; 432 bool resume = true;
425 if (defer_state_ == DEFERRED_UNCHECKED_REDIRECT) { 433 if (defer_state_ == DEFERRED_UNCHECKED_REDIRECT) {
426 // Save the redirect urls for possible malware detail reporting later. 434 // Save the redirect urls for possible malware detail reporting later.
427 redirect_urls_.push_back(unchecked_redirect_url_); 435 redirect_urls_.push_back(unchecked_redirect_url_);
428 if (!CheckUrl(unchecked_redirect_url_)) { 436 if (!CheckUrl(unchecked_redirect_url_)) {
429 // We're now waiting for the unchecked_redirect_url_. 437 // We're now waiting for the unchecked_redirect_url_.
430 defer_state_ = DEFERRED_REDIRECT; 438 defer_state_ = DEFERRED_REDIRECT;
431 resume = false; 439 resume = false;
432 BeginNetLogEvent(NetLogEventType::SAFE_BROWSING_DEFERRED, 440 BeginNetLogEvent(NetLogEventType::SAFE_BROWSING_DEFERRED,
433 unchecked_redirect_url_, "defer_reason", 441 unchecked_redirect_url_, "defer_reason",
434 "resumed_redirect"); 442 "resumed_redirect");
435 } 443 }
436 } 444 }
437 445
438 if (resume) { 446 if (resume) {
439 defer_state_ = DEFERRED_NONE; 447 defer_state_ = DEFERRED_NONE;
440 Resume(); 448 Resume();
441 } 449 }
442 } 450 }
OLDNEW
« no previous file with comments | « chrome/browser/loader/safe_browsing_resource_throttle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698