| OLD | NEW |
| 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/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 13 #include "base/values.h" | 14 #include "base/values.h" |
| 14 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/prerender/prerender_contents.h" | 16 #include "chrome/browser/prerender/prerender_contents.h" |
| 16 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 17 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 17 #include "components/safe_browsing_db/util.h" | 18 #include "components/safe_browsing_db/util.h" |
| 18 #include "components/safe_browsing_db/v4_feature_list.h" | 19 #include "components/safe_browsing_db/v4_feature_list.h" |
| 19 #include "components/safe_browsing_db/v4_local_database_manager.h" | 20 #include "components/safe_browsing_db/v4_local_database_manager.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 return "SafeBrowsingResourceThrottle"; | 227 return "SafeBrowsingResourceThrottle"; |
| 227 } | 228 } |
| 228 | 229 |
| 229 // SafeBrowsingService::Client implementation, called on the IO thread once | 230 // SafeBrowsingService::Client implementation, called on the IO thread once |
| 230 // the URL has been classified. | 231 // the URL has been classified. |
| 231 void SafeBrowsingResourceThrottle::OnCheckBrowseUrlResult( | 232 void SafeBrowsingResourceThrottle::OnCheckBrowseUrlResult( |
| 232 const GURL& url, | 233 const GURL& url, |
| 233 safe_browsing::SBThreatType threat_type, | 234 safe_browsing::SBThreatType threat_type, |
| 234 const safe_browsing::ThreatMetadata& metadata) { | 235 const safe_browsing::ThreatMetadata& metadata) { |
| 235 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 |
| 238 // removed after http://crbug.com/660293 is fixed. |
| 236 CHECK(url.is_valid()); | 239 CHECK(url.is_valid()); |
| 237 CHECK(url_being_checked_.is_valid()); | 240 CHECK(url_being_checked_.is_valid()); |
| 238 CHECK_EQ(url, url_being_checked_); | 241 if (url != url_being_checked_) { |
| 242 char buf[2000]; |
| 243 snprintf(buf, sizeof(buf), "sbtr::ocbur:%s -- %s\n", url.spec().c_str(), |
| 244 url_being_checked_.spec().c_str()); |
| 245 base::debug::Alias(buf); |
| 246 CHECK(false) << "buf: " << buf; |
| 247 } |
| 239 | 248 |
| 240 timer_.Stop(); // Cancel the timeout timer. | 249 timer_.Stop(); // Cancel the timeout timer. |
| 241 threat_type_ = threat_type; | 250 threat_type_ = threat_type; |
| 242 state_ = STATE_NONE; | 251 state_ = STATE_NONE; |
| 243 | 252 |
| 244 if (defer_state_ != DEFERRED_NONE) { | 253 if (defer_state_ != DEFERRED_NONE) { |
| 245 EndNetLogEvent(NetLogEventType::SAFE_BROWSING_DEFERRED, nullptr, nullptr); | 254 EndNetLogEvent(NetLogEventType::SAFE_BROWSING_DEFERRED, nullptr, nullptr); |
| 246 } | 255 } |
| 247 EndNetLogEvent( | 256 EndNetLogEvent( |
| 248 NetLogEventType::SAFE_BROWSING_CHECKING_URL, "result", | 257 NetLogEventType::SAFE_BROWSING_CHECKING_URL, "result", |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 unchecked_redirect_url_, "defer_reason", | 438 unchecked_redirect_url_, "defer_reason", |
| 430 "resumed_redirect"); | 439 "resumed_redirect"); |
| 431 } | 440 } |
| 432 } | 441 } |
| 433 | 442 |
| 434 if (resume) { | 443 if (resume) { |
| 435 defer_state_ = DEFERRED_NONE; | 444 defer_state_ = DEFERRED_NONE; |
| 436 controller()->Resume(); | 445 controller()->Resume(); |
| 437 } | 446 } |
| 438 } | 447 } |
| OLD | NEW |