| 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
| 6 | 6 |
| 7 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 7 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 GlobalRequestID(child_id, request_id)); | 1163 GlobalRequestID(child_id, request_id)); |
| 1164 if (i == pending_requests_.end()) { | 1164 if (i == pending_requests_.end()) { |
| 1165 // We probably want to remove this warning eventually, but I wanted to be | 1165 // We probably want to remove this warning eventually, but I wanted to be |
| 1166 // able to notice when this happens during initial development since it | 1166 // able to notice when this happens during initial development since it |
| 1167 // should be rare and may indicate a bug. | 1167 // should be rare and may indicate a bug. |
| 1168 DLOG(WARNING) << "Canceling a request that wasn't found"; | 1168 DLOG(WARNING) << "Canceling a request that wasn't found"; |
| 1169 return; | 1169 return; |
| 1170 } | 1170 } |
| 1171 net::URLRequest* request = i->second; | 1171 net::URLRequest* request = i->second; |
| 1172 const bool started_before_cancel = request->is_pending(); | 1172 const bool started_before_cancel = request->is_pending(); |
| 1173 CancelRequestInternal(request, from_renderer); | 1173 |
| 1174 // If the request isn't in flight, then we won't get asyncronous notification, | 1174 if (CancelRequestInternal(request, from_renderer) && |
| 1175 // so we have to signal ourselves to finish this request. | 1175 !started_before_cancel) { |
| 1176 if (!started_before_cancel) | 1176 // If the request isn't in flight, then we won't get asyncronous |
| 1177 // notification, so we have to signal ourselves to finish this |
| 1178 // request. |
| 1177 OnResponseCompleted(request); | 1179 OnResponseCompleted(request); |
| 1180 } |
| 1178 } | 1181 } |
| 1179 | 1182 |
| 1180 void ResourceDispatcherHost::CancelRequestInternal(net::URLRequest* request, | 1183 bool ResourceDispatcherHost::CancelRequestInternal(net::URLRequest* request, |
| 1181 bool from_renderer) { | 1184 bool from_renderer) { |
| 1182 VLOG(1) << "CancelRequest: " << request->url().spec(); | 1185 VLOG(1) << "CancelRequest: " << request->url().spec(); |
| 1183 | 1186 |
| 1184 // WebKit will send us a cancel for downloads since it no longer handles them. | 1187 // WebKit will send us a cancel for downloads since it no longer handles them. |
| 1185 // In this case, ignore the cancel since we handle downloads in the browser. | 1188 // In this case, ignore the cancel since we handle downloads in the browser. |
| 1186 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1189 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); |
| 1187 if (!from_renderer || !info->is_download()) { | 1190 if (!from_renderer || !info->is_download()) { |
| 1188 if (info->login_handler()) { | 1191 if (info->login_handler()) { |
| 1189 info->login_handler()->OnRequestCancelled(); | 1192 info->login_handler()->OnRequestCancelled(); |
| 1190 info->set_login_handler(NULL); | 1193 info->set_login_handler(NULL); |
| 1191 } | 1194 } |
| 1192 if (info->ssl_client_auth_handler()) { | 1195 if (info->ssl_client_auth_handler()) { |
| 1193 info->ssl_client_auth_handler()->OnRequestCancelled(); | 1196 info->ssl_client_auth_handler()->OnRequestCancelled(); |
| 1194 info->set_ssl_client_auth_handler(NULL); | 1197 info->set_ssl_client_auth_handler(NULL); |
| 1195 } | 1198 } |
| 1196 request->Cancel(); | 1199 request->Cancel(); |
| 1197 // Our callers assume |request| is valid after we return. | 1200 // Our callers assume |request| is valid after we return. |
| 1198 DCHECK(IsValidRequest(request)); | 1201 DCHECK(IsValidRequest(request)); |
| 1202 return true; |
| 1199 } | 1203 } |
| 1200 | 1204 |
| 1201 // Do not remove from the pending requests, as the request will still | 1205 // Do not remove from the pending requests, as the request will still |
| 1202 // call AllDataReceived, and may even have more data before it does | 1206 // call AllDataReceived, and may even have more data before it does |
| 1203 // that. | 1207 // that. |
| 1208 return false; |
| 1204 } | 1209 } |
| 1205 | 1210 |
| 1206 int ResourceDispatcherHost::IncrementOutstandingRequestsMemoryCost( | 1211 int ResourceDispatcherHost::IncrementOutstandingRequestsMemoryCost( |
| 1207 int cost, | 1212 int cost, |
| 1208 int child_id) { | 1213 int child_id) { |
| 1209 // Retrieve the previous value (defaulting to 0 if not found). | 1214 // Retrieve the previous value (defaulting to 0 if not found). |
| 1210 OutstandingRequestsMemoryCostMap::iterator prev_entry = | 1215 OutstandingRequestsMemoryCostMap::iterator prev_entry = |
| 1211 outstanding_requests_memory_cost_map_.find(child_id); | 1216 outstanding_requests_memory_cost_map_.find(child_id); |
| 1212 int new_cost = 0; | 1217 int new_cost = 0; |
| 1213 if (prev_entry != outstanding_requests_memory_cost_map_.end()) | 1218 if (prev_entry != outstanding_requests_memory_cost_map_.end()) |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1941 return is_prefetch_enabled_; | 1946 return is_prefetch_enabled_; |
| 1942 } | 1947 } |
| 1943 | 1948 |
| 1944 // static | 1949 // static |
| 1945 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { | 1950 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { |
| 1946 is_prefetch_enabled_ = value; | 1951 is_prefetch_enabled_ = value; |
| 1947 } | 1952 } |
| 1948 | 1953 |
| 1949 // static | 1954 // static |
| 1950 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; | 1955 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; |
| OLD | NEW |