OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/global_request_id.h" | 8 #include "chrome/browser/renderer_host/global_request_id.h" |
9 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 9 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
10 #include "chrome/browser/renderer_host/resource_message_filter.h" | 10 #include "chrome/browser/renderer_host/resource_message_filter.h" |
11 #include "chrome/common/resource_response.h" | 11 #include "chrome/common/resource_response.h" |
12 #include "net/base/io_buffer.h" | |
13 #include "net/base/load_flags.h" | |
12 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
13 #include "net/base/io_buffer.h" | |
14 | 15 |
15 // Maximum time in milliseconds to wait for the safe browsing service to | 16 // Maximum time in milliseconds to wait for the safe browsing service to |
16 // verify a URL. After this amount of time the outstanding check will be | 17 // verify a URL. After this amount of time the outstanding check will be |
17 // aborted, and the URL will be treated as if it were safe. | 18 // aborted, and the URL will be treated as if it were safe. |
18 static const int kCheckUrlTimeoutMs = 5000; | 19 static const int kCheckUrlTimeoutMs = 5000; |
19 | 20 |
20 // TODO(eroman): Downgrade these CHECK()s to DCHECKs once there is more | 21 // TODO(eroman): Downgrade these CHECK()s to DCHECKs once there is more |
21 // unit test coverage. | 22 // unit test coverage. |
22 | 23 |
23 SafeBrowsingResourceHandler::SafeBrowsingResourceHandler( | 24 SafeBrowsingResourceHandler::SafeBrowsingResourceHandler( |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 | 152 |
152 if (result == SafeBrowsingService::SAFE) { | 153 if (result == SafeBrowsingService::SAFE) { |
153 // Log how much time the safe browsing check cost us. | 154 // Log how much time the safe browsing check cost us. |
154 base::TimeDelta pause_delta; | 155 base::TimeDelta pause_delta; |
155 pause_delta = base::TimeTicks::Now() - url_check_start_time_; | 156 pause_delta = base::TimeTicks::Now() - url_check_start_time_; |
156 safe_browsing_->LogPauseDelay(pause_delta); | 157 safe_browsing_->LogPauseDelay(pause_delta); |
157 | 158 |
158 // Continue the request. | 159 // Continue the request. |
159 ResumeRequest(); | 160 ResumeRequest(); |
160 } else { | 161 } else { |
162 const net::URLRequest* request = rdh_->GetURLRequest( | |
163 GlobalRequestID(render_process_host_id_, deferred_request_id_)); | |
164 if (request->load_flags() & net::LOAD_PREFETCH) { | |
165 // Don't prefetch resources that fail safe browsing, disallow | |
166 // them. | |
167 rdh_->CancelRequest(render_process_host_id_, deferred_request_id_, false); | |
168 // TODO(gavinp): reevaluate fixing this if bug 73778. | |
169 next_handler_->OnResponseCompleted( | |
lzheng
2011/02/23 02:19:12
I read your reply to Chris's question, but I still
rvargas (doing something else)
2011/02/23 03:49:51
I see what's going on here. The problem is that UR
gavinp
2011/03/07 23:26:40
OMG, Thanks for setting my head straight.
I've no
| |
170 deferred_request_id_, | |
171 net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_ABORTED) , | |
lzheng
2011/02/23 02:19:12
80 chars.
gavinp
2011/03/07 23:26:40
Done.
| |
172 std::string()); | |
173 return; | |
lzheng
2011/02/23 02:19:12
Can't return here without calling Release. How abo
gavinp
2011/03/07 23:26:40
Done.
| |
174 } | |
161 StartDisplayingBlockingPage(url, result); | 175 StartDisplayingBlockingPage(url, result); |
162 } | 176 } |
163 | 177 |
164 Release(); // Balances the AddRef() in CheckingUrl(). | 178 Release(); // Balances the AddRef() in CheckingUrl(). |
165 } | 179 } |
166 | 180 |
167 void SafeBrowsingResourceHandler::StartDisplayingBlockingPage( | 181 void SafeBrowsingResourceHandler::StartDisplayingBlockingPage( |
168 const GURL& url, | 182 const GURL& url, |
169 SafeBrowsingService::UrlCheckResult result) { | 183 SafeBrowsingService::UrlCheckResult result) { |
170 CHECK(state_ == STATE_NONE); | 184 CHECK(state_ == STATE_NONE); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 rdh_->FollowDeferredRedirect(render_process_host_id_, request_id, | 311 rdh_->FollowDeferredRedirect(render_process_host_id_, request_id, |
298 false, GURL()); | 312 false, GURL()); |
299 } | 313 } |
300 } | 314 } |
301 | 315 |
302 void SafeBrowsingResourceHandler::ClearDeferredRequestInfo() { | 316 void SafeBrowsingResourceHandler::ClearDeferredRequestInfo() { |
303 deferred_request_id_ = -1; | 317 deferred_request_id_ = -1; |
304 deferred_url_ = GURL(); | 318 deferred_url_ = GURL(); |
305 deferred_redirect_response_ = NULL; | 319 deferred_redirect_response_ = NULL; |
306 } | 320 } |
OLD | NEW |