OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/renderer_host/safe_browsing_resource_handler.h" | 5 #include "chrome/browser/renderer_host/safe_browsing_resource_handler.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 8 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
9 #include "chrome/browser/renderer_host/resource_message_filter.h" | 9 #include "chrome/browser/renderer_host/resource_message_filter.h" |
10 #include "chrome/common/notification_service.h" | 10 #include "chrome/common/notification_service.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 int request_id, ResourceResponse* response) { | 83 int request_id, ResourceResponse* response) { |
84 CHECK(state_ == STATE_NONE); | 84 CHECK(state_ == STATE_NONE); |
85 CHECK(defer_state_ == DEFERRED_NONE); | 85 CHECK(defer_state_ == DEFERRED_NONE); |
86 return next_handler_->OnResponseStarted(request_id, response); | 86 return next_handler_->OnResponseStarted(request_id, response); |
87 } | 87 } |
88 | 88 |
89 void SafeBrowsingResourceHandler::OnCheckUrlTimeout() { | 89 void SafeBrowsingResourceHandler::OnCheckUrlTimeout() { |
90 CHECK(state_ == STATE_CHECKING_URL); | 90 CHECK(state_ == STATE_CHECKING_URL); |
91 CHECK(defer_state_ != DEFERRED_NONE); | 91 CHECK(defer_state_ != DEFERRED_NONE); |
92 safe_browsing_->CancelCheck(this); | 92 safe_browsing_->CancelCheck(this); |
93 OnUrlCheckResult(GURL(), SafeBrowsingService::URL_SAFE); | 93 OnUrlCheckResult(deferred_url_, SafeBrowsingService::URL_SAFE); |
94 } | 94 } |
95 | 95 |
96 bool SafeBrowsingResourceHandler::OnWillStart(int request_id, | 96 bool SafeBrowsingResourceHandler::OnWillStart(int request_id, |
97 const GURL& url, | 97 const GURL& url, |
98 bool* defer) { | 98 bool* defer) { |
99 // We need to check the new URL before starting the request. | 99 // We need to check the new URL before starting the request. |
100 if (CheckUrl(url)) | 100 if (CheckUrl(url)) |
101 return next_handler_->OnWillStart(request_id, url, defer); | 101 return next_handler_->OnWillStart(request_id, url, defer); |
102 | 102 |
103 // If the URL couldn't be verified synchronously, defer starting the | 103 // If the URL couldn't be verified synchronously, defer starting the |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 void SafeBrowsingResourceHandler::OnRequestClosed() { | 140 void SafeBrowsingResourceHandler::OnRequestClosed() { |
141 next_handler_->OnRequestClosed(); | 141 next_handler_->OnRequestClosed(); |
142 } | 142 } |
143 | 143 |
144 // SafeBrowsingService::Client implementation, called on the IO thread once | 144 // SafeBrowsingService::Client implementation, called on the IO thread once |
145 // the URL has been classified. | 145 // the URL has been classified. |
146 void SafeBrowsingResourceHandler::OnUrlCheckResult( | 146 void SafeBrowsingResourceHandler::OnUrlCheckResult( |
147 const GURL& url, SafeBrowsingService::UrlCheckResult result) { | 147 const GURL& url, SafeBrowsingService::UrlCheckResult result) { |
148 CHECK(state_ == STATE_CHECKING_URL); | 148 CHECK(state_ == STATE_CHECKING_URL); |
149 CHECK(defer_state_ != DEFERRED_NONE); | 149 CHECK(defer_state_ != DEFERRED_NONE); |
150 CHECK(url == deferred_url_); | 150 CHECK(url == deferred_url_) << "Was expecting: " << deferred_url_ |
wtc
2010/03/02 21:37:08
If the |url| argument must be equal to the |deferr
eroman
2010/03/02 21:44:19
The redirect bug would be failing in this method,
| |
151 << " but got: " << url; | |
151 | 152 |
152 timer_.Stop(); // Cancel the timeout timer. | 153 timer_.Stop(); // Cancel the timeout timer. |
153 safe_browsing_result_ = result; | 154 safe_browsing_result_ = result; |
154 state_ = STATE_NONE; | 155 state_ = STATE_NONE; |
155 | 156 |
156 if (result == SafeBrowsingService::URL_SAFE) { | 157 if (result == SafeBrowsingService::URL_SAFE) { |
157 // Log how much time the safe browsing check cost us. | 158 // Log how much time the safe browsing check cost us. |
158 base::TimeDelta pause_delta; | 159 base::TimeDelta pause_delta; |
159 pause_delta = base::TimeTicks::Now() - url_check_start_time_; | 160 pause_delta = base::TimeTicks::Now() - url_check_start_time_; |
160 safe_browsing_->LogPauseDelay(pause_delta); | 161 safe_browsing_->LogPauseDelay(pause_delta); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 rdh_->FollowDeferredRedirect(render_process_host_id_, request_id, | 294 rdh_->FollowDeferredRedirect(render_process_host_id_, request_id, |
294 false, GURL()); | 295 false, GURL()); |
295 } | 296 } |
296 } | 297 } |
297 | 298 |
298 void SafeBrowsingResourceHandler::ClearDeferredRequestInfo() { | 299 void SafeBrowsingResourceHandler::ClearDeferredRequestInfo() { |
299 deferred_request_id_ = -1; | 300 deferred_request_id_ = -1; |
300 deferred_url_ = GURL(); | 301 deferred_url_ = GURL(); |
301 deferred_redirect_response_ = NULL; | 302 deferred_redirect_response_ = NULL; |
302 } | 303 } |
OLD | NEW |