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

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

Issue 2542373002: RB-B P1 issue: Add debug aliases for state_ and urls to debug CHECK failures (Closed)
Patch Set: Add TODO to remove debugging code after fixing bug Created 4 years 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 | « no previous file | 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/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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 const char* SafeBrowsingResourceThrottle::GetNameForLogging() const { 226 const char* SafeBrowsingResourceThrottle::GetNameForLogging() const {
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 // TODO(vakh): The following base::debug::Alias() calls should be removed and
236 CHECK(url.is_valid()); 237 // CHECKs corrected after http://crbug.com/660293 is fixed.
237 CHECK(url_being_checked_.is_valid()); 238 base::debug::Alias(&state_);
238 CHECK_EQ(url, url_being_checked_); 239 base::debug::Alias(&url);
240 base::debug::Alias(&url_being_checked_);
Scott Hess - ex-Googler 2016/12/02 04:19:27 I am not sure that these work. They'll annotate t
241 std::string alias_str = base::StringPrintf(
242 "OnCheckBrowseUrlResult: state_: %d, url: %s, url_being_checked_: %s",
243 state_, url.spec().c_str(), url_being_checked_.spec().c_str());
Scott Hess - ex-Googler 2016/12/02 04:19:27 In fact, I'm not even sure this will work, because
244 base::debug::Alias(&alias_str);
245 if (!url_being_checked_.is_valid()) {
246 CHECK(false);
247 }
248 if (!url.is_valid()) {
249 CHECK(false);
250 }
251 if (url != url_being_checked_) {
252 CHECK(false);
253 }
254 if (state_ != STATE_CHECKING_URL) {
255 CHECK(false);
256 }
239 257
240 timer_.Stop(); // Cancel the timeout timer. 258 timer_.Stop(); // Cancel the timeout timer.
241 threat_type_ = threat_type; 259 threat_type_ = threat_type;
242 state_ = STATE_NONE; 260 state_ = STATE_NONE;
243 261
244 if (defer_state_ != DEFERRED_NONE) { 262 if (defer_state_ != DEFERRED_NONE) {
245 EndNetLogEvent(NetLogEventType::SAFE_BROWSING_DEFERRED, nullptr, nullptr); 263 EndNetLogEvent(NetLogEventType::SAFE_BROWSING_DEFERRED, nullptr, nullptr);
246 } 264 }
247 EndNetLogEvent( 265 EndNetLogEvent(
248 NetLogEventType::SAFE_BROWSING_CHECKING_URL, "result", 266 NetLogEventType::SAFE_BROWSING_CHECKING_URL, "result",
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 unchecked_redirect_url_, "defer_reason", 447 unchecked_redirect_url_, "defer_reason",
430 "resumed_redirect"); 448 "resumed_redirect");
431 } 449 }
432 } 450 }
433 451
434 if (resume) { 452 if (resume) {
435 defer_state_ = DEFERRED_NONE; 453 defer_state_ = DEFERRED_NONE;
436 controller()->Resume(); 454 controller()->Resume();
437 } 455 }
438 } 456 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698