OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/renderer_host/resource_dispatcher_host.h" | 8 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
8 #include "chrome/browser/renderer_host/resource_message_filter.h" | 9 #include "chrome/browser/renderer_host/resource_message_filter.h" |
9 #include "chrome/common/notification_service.h" | 10 #include "chrome/common/notification_service.h" |
10 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
| 12 #include "net/base/io_buffer.h" |
11 | 13 |
12 // Maximum time to wait for a gethash response from the Safe Browsing servers. | 14 // Maximum time to wait for a gethash response from the Safe Browsing servers. |
13 static const int kMaxGetHashMs = 1000; | 15 static const int kMaxGetHashMs = 1000; |
14 | 16 |
15 SafeBrowsingResourceHandler::SafeBrowsingResourceHandler( | 17 SafeBrowsingResourceHandler::SafeBrowsingResourceHandler( |
16 ResourceHandler* handler, | 18 ResourceHandler* handler, |
17 int render_process_host_id, | 19 int render_process_host_id, |
18 int render_view_id, | 20 int render_view_id, |
19 const GURL& url, | 21 const GURL& url, |
20 ResourceType::Type resource_type, | 22 ResourceType::Type resource_type, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 FROM_HERE, | 98 FROM_HERE, |
97 NewRunnableMethod(this, &SafeBrowsingResourceHandler::OnGetHashTimeout), | 99 NewRunnableMethod(this, &SafeBrowsingResourceHandler::OnGetHashTimeout), |
98 kMaxGetHashMs); | 100 kMaxGetHashMs); |
99 } | 101 } |
100 | 102 |
101 if (in_safe_browsing_check_ || displaying_blocking_page_) { | 103 if (in_safe_browsing_check_ || displaying_blocking_page_) { |
102 rdh_->PauseRequest(render_process_host_id_, request_id, true); | 104 rdh_->PauseRequest(render_process_host_id_, request_id, true); |
103 paused_request_id_ = request_id; | 105 paused_request_id_ = request_id; |
104 } | 106 } |
105 | 107 |
106 return next_handler_->OnWillRead(request_id, buf, buf_size, min_size); | 108 bool rv = next_handler_->OnWillRead(request_id, buf, buf_size, min_size); |
| 109 // TODO(willchan): Remove after debugging bug 16371. |
| 110 if (rv) |
| 111 CHECK((*buf)->data()); |
| 112 return rv; |
107 } | 113 } |
108 | 114 |
109 bool SafeBrowsingResourceHandler::OnReadCompleted(int request_id, | 115 bool SafeBrowsingResourceHandler::OnReadCompleted(int request_id, |
110 int* bytes_read) { | 116 int* bytes_read) { |
111 return next_handler_->OnReadCompleted(request_id, bytes_read); | 117 return next_handler_->OnReadCompleted(request_id, bytes_read); |
112 } | 118 } |
113 | 119 |
114 bool SafeBrowsingResourceHandler::OnResponseCompleted( | 120 bool SafeBrowsingResourceHandler::OnResponseCompleted( |
115 int request_id, const URLRequestStatus& status, | 121 int request_id, const URLRequestStatus& status, |
116 const std::string& security_info) { | 122 const std::string& security_info) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 void SafeBrowsingResourceHandler::Observe(NotificationType type, | 204 void SafeBrowsingResourceHandler::Observe(NotificationType type, |
199 const NotificationSource& source, | 205 const NotificationSource& source, |
200 const NotificationDetails& details) { | 206 const NotificationDetails& details) { |
201 DCHECK(type.value == NotificationType::RESOURCE_MESSAGE_FILTER_SHUTDOWN); | 207 DCHECK(type.value == NotificationType::RESOURCE_MESSAGE_FILTER_SHUTDOWN); |
202 if (in_safe_browsing_check_) { | 208 if (in_safe_browsing_check_) { |
203 safe_browsing_->CancelCheck(this); | 209 safe_browsing_->CancelCheck(this); |
204 in_safe_browsing_check_ = false; | 210 in_safe_browsing_check_ = false; |
205 Release(); | 211 Release(); |
206 } | 212 } |
207 } | 213 } |
208 | |
OLD | NEW |