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

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

Issue 2626153003: [M56] 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
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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 void SafeBrowsingResourceThrottle::OnCheckBrowseUrlResult( 232 void SafeBrowsingResourceThrottle::OnCheckBrowseUrlResult(
233 const GURL& url, 233 const GURL& url,
234 safe_browsing::SBThreatType threat_type, 234 safe_browsing::SBThreatType threat_type,
235 const safe_browsing::ThreatMetadata& metadata) { 235 const safe_browsing::ThreatMetadata& metadata) {
236 CHECK_EQ(state_, STATE_CHECKING_URL); 236 CHECK_EQ(state_, STATE_CHECKING_URL);
237 // TODO(vakh): The following base::debug::Alias() and CHECK calls should be 237 // TODO(vakh): The following base::debug::Alias() and CHECK calls should be
238 // removed after http://crbug.com/660293 is fixed. 238 // removed after http://crbug.com/660293 is fixed.
239 CHECK(url.is_valid()); 239 CHECK(url.is_valid());
240 CHECK(url_being_checked_.is_valid()); 240 CHECK(url_being_checked_.is_valid());
241 if (url != url_being_checked_) { 241 if (url != url_being_checked_) {
242 char buf[2000]; 242 bool url_had_timed_out = timed_out_urls_.count(url) > 0;
243 snprintf(buf, sizeof(buf), "sbtr::ocbur:%s -- %s\n", url.spec().c_str(), 243 char buf[1000];
244 url_being_checked_.spec().c_str()); 244 snprintf(buf, sizeof(buf), "sbtr::ocbur:%d:%s -- %s\n", url_had_timed_out,
245 url.spec().c_str(), url_being_checked_.spec().c_str());
245 base::debug::Alias(buf); 246 base::debug::Alias(buf);
246 CHECK(false) << "buf: " << buf; 247 CHECK(false) << "buf: " << buf;
247 } 248 }
248 249
249 timer_.Stop(); // Cancel the timeout timer. 250 timer_.Stop(); // Cancel the timeout timer.
250 threat_type_ = threat_type; 251 threat_type_ = threat_type;
251 state_ = STATE_NONE; 252 state_ = STATE_NONE;
252 253
253 if (defer_state_ != DEFERRED_NONE) { 254 if (defer_state_ != DEFERRED_NONE) {
254 EndNetLogEvent(NetLogEventType::SAFE_BROWSING_DEFERRED, nullptr, nullptr); 255 EndNetLogEvent(NetLogEventType::SAFE_BROWSING_DEFERRED, nullptr, nullptr);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 return false; 414 return false;
414 } 415 }
415 416
416 void SafeBrowsingResourceThrottle::OnCheckUrlTimeout() { 417 void SafeBrowsingResourceThrottle::OnCheckUrlTimeout() {
417 CHECK_EQ(state_, STATE_CHECKING_URL); 418 CHECK_EQ(state_, STATE_CHECKING_URL);
418 419
419 database_manager_->CancelCheck(this); 420 database_manager_->CancelCheck(this);
420 421
421 OnCheckBrowseUrlResult(url_being_checked_, safe_browsing::SB_THREAT_TYPE_SAFE, 422 OnCheckBrowseUrlResult(url_being_checked_, safe_browsing::SB_THREAT_TYPE_SAFE,
422 safe_browsing::ThreatMetadata()); 423 safe_browsing::ThreatMetadata());
424
425 timed_out_urls_.insert(url_being_checked_);
423 } 426 }
424 427
425 void SafeBrowsingResourceThrottle::ResumeRequest() { 428 void SafeBrowsingResourceThrottle::ResumeRequest() {
426 CHECK_EQ(state_, STATE_NONE); 429 CHECK_EQ(state_, STATE_NONE);
427 CHECK_NE(defer_state_, DEFERRED_NONE); 430 CHECK_NE(defer_state_, DEFERRED_NONE);
428 431
429 bool resume = true; 432 bool resume = true;
430 if (defer_state_ == DEFERRED_UNCHECKED_REDIRECT) { 433 if (defer_state_ == DEFERRED_UNCHECKED_REDIRECT) {
431 // Save the redirect urls for possible malware detail reporting later. 434 // Save the redirect urls for possible malware detail reporting later.
432 redirect_urls_.push_back(unchecked_redirect_url_); 435 redirect_urls_.push_back(unchecked_redirect_url_);
433 if (!CheckUrl(unchecked_redirect_url_)) { 436 if (!CheckUrl(unchecked_redirect_url_)) {
434 // We're now waiting for the unchecked_redirect_url_. 437 // We're now waiting for the unchecked_redirect_url_.
435 defer_state_ = DEFERRED_REDIRECT; 438 defer_state_ = DEFERRED_REDIRECT;
436 resume = false; 439 resume = false;
437 BeginNetLogEvent(NetLogEventType::SAFE_BROWSING_DEFERRED, 440 BeginNetLogEvent(NetLogEventType::SAFE_BROWSING_DEFERRED,
438 unchecked_redirect_url_, "defer_reason", 441 unchecked_redirect_url_, "defer_reason",
439 "resumed_redirect"); 442 "resumed_redirect");
440 } 443 }
441 } 444 }
442 445
443 if (resume) { 446 if (resume) {
444 defer_state_ = DEFERRED_NONE; 447 defer_state_ = DEFERRED_NONE;
445 controller()->Resume(); 448 controller()->Resume();
446 } 449 }
447 } 450 }
OLDNEW
« no previous file with comments | « chrome/browser/loader/safe_browsing_resource_throttle.h ('k') | components/safe_browsing_db/v4_local_database_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698