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

Unified Diff: content/browser/renderer_host/resource_dispatcher_host_impl.cc

Issue 10644011: Revert r143458 (which re-applies r143341 and r142979). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/resource_dispatcher_host_impl.cc
===================================================================
--- content/browser/renderer_host/resource_dispatcher_host_impl.cc (revision 143642)
+++ content/browser/renderer_host/resource_dispatcher_host_impl.cc (working copy)
@@ -99,10 +99,6 @@
// The interval for calls to ResourceDispatcherHostImpl::UpdateLoadStates
const int kUpdateLoadStatesIntervalMsec = 100;
-// Maximum number of pending data messages sent to the renderer at any
-// given time for a given request.
-const int kMaxPendingDataMessages = 20;
-
// Maximum byte "cost" of all the outstanding requests for a renderer.
// See delcaration of |max_outstanding_requests_cost_per_process_| for details.
// This bound is 25MB, which allows for around 6000 outstanding requests.
@@ -930,22 +926,6 @@
return;
}
- // Construct the event handler.
- scoped_ptr<ResourceHandler> handler;
- if (sync_result) {
- handler.reset(new SyncResourceHandler(
- filter_, request_data.url, sync_result, this));
- } else {
- handler.reset(new AsyncResourceHandler(
- filter_, route_id, request_data.url, this));
- }
-
- // The RedirectToFileResourceHandler depends on being next in the chain.
- if (request_data.download_to_file) {
- handler.reset(
- new RedirectToFileResourceHandler(handler.Pass(), child_id, this));
- }
-
int load_flags =
BuildLoadFlagsForRequest(request_data, child_id, sync_result != NULL);
@@ -987,6 +967,61 @@
upload_size = request_data.upload_data->GetContentLengthSync();
}
+ bool allow_download = request_data.allow_download &&
+ ResourceType::IsFrame(request_data.resource_type);
+
+ // Make extra info and read footer (contains request ID).
+ ResourceRequestInfoImpl* extra_info =
+ new ResourceRequestInfoImpl(
+ process_type,
+ child_id,
+ route_id,
+ request_data.origin_pid,
+ request_id,
+ request_data.is_main_frame,
+ request_data.frame_id,
+ request_data.parent_is_main_frame,
+ request_data.parent_frame_id,
+ request_data.resource_type,
+ request_data.transition_type,
+ upload_size,
+ false, // is download
+ allow_download,
+ request_data.has_user_gesture,
+ request_data.referrer_policy,
+ resource_context);
+ extra_info->AssociateWithRequest(request); // Request takes ownership.
+
+ if (request->url().SchemeIs(chrome::kBlobScheme)) {
+ // Hang on to a reference to ensure the blob is not released prior
+ // to the job being started.
+ webkit_blob::BlobStorageController* controller =
+ GetBlobStorageControllerForResourceContext(resource_context);
+ extra_info->set_requested_blob_data(
+ controller->GetBlobDataFromUrl(request->url()));
+ }
+
+ // Have the appcache associate its extra info with the request.
+ appcache::AppCacheInterceptor::SetExtraRequestInfo(
+ request, ResourceContext::GetAppCacheService(resource_context), child_id,
+ request_data.appcache_host_id, request_data.resource_type);
+
+ // Construct the IPC resource handler.
+ scoped_ptr<ResourceHandler> handler;
darin (slow to review) 2012/06/22 19:56:03 btw, the point of this code move is to just ensure
+ if (sync_result) {
+ handler.reset(new SyncResourceHandler(
+ filter_, request, sync_result, this));
+ } else {
+ handler.reset(new AsyncResourceHandler(
+ filter_, route_id, request, this));
+ }
+
+ // The RedirectToFileResourceHandler depends on being next in the chain.
+ if (request_data.download_to_file) {
+ handler.reset(
+ new RedirectToFileResourceHandler(handler.Pass(), child_id, this));
+ }
+
// Install a CrossSiteResourceHandler if this request is coming from a
// RenderViewHost with a pending cross-site request. We only check this for
// MAIN_FRAME requests. Unblock requests only come from a blocked page, do
@@ -997,8 +1032,8 @@
HasPendingCrossSiteRequest(child_id, route_id)) {
// Wrap the event handler to be sure the current page's onunload handler
// has a chance to run before we render the new page.
- handler.reset(
- new CrossSiteResourceHandler(handler.Pass(), child_id, route_id, this));
+ handler.reset(new CrossSiteResourceHandler(handler.Pass(), child_id,
+ route_id, request));
}
// Insert a buffered event handler before the actual one.
@@ -1031,44 +1066,6 @@
throttles.Pass()));
}
- bool allow_download = request_data.allow_download &&
- ResourceType::IsFrame(request_data.resource_type);
- // Make extra info and read footer (contains request ID).
- ResourceRequestInfoImpl* extra_info =
- new ResourceRequestInfoImpl(
- process_type,
- child_id,
- route_id,
- request_data.origin_pid,
- request_id,
- request_data.is_main_frame,
- request_data.frame_id,
- request_data.parent_is_main_frame,
- request_data.parent_frame_id,
- request_data.resource_type,
- request_data.transition_type,
- upload_size,
- false, // is download
- allow_download,
- request_data.has_user_gesture,
- request_data.referrer_policy,
- resource_context);
- extra_info->AssociateWithRequest(request); // Request takes ownership.
-
- if (request->url().SchemeIs(chrome::kBlobScheme)) {
- // Hang on to a reference to ensure the blob is not released prior
- // to the job being started.
- webkit_blob::BlobStorageController* controller =
- GetBlobStorageControllerForResourceContext(resource_context);
- extra_info->set_requested_blob_data(
- controller->GetBlobDataFromUrl(request->url()));
- }
-
- // Have the appcache associate its extra info with the request.
- appcache::AppCacheInterceptor::SetExtraRequestInfo(
- request, ResourceContext::GetAppCacheService(resource_context), child_id,
- request_data.appcache_host_id, request_data.resource_type);
-
if (deferred_loader.get()) {
pending_loaders_[extra_info->GetGlobalRequestID()] = deferred_loader;
deferred_loader->CompleteTransfer(handler.Pass());
@@ -1082,33 +1079,13 @@
}
void ResourceDispatcherHostImpl::OnDataReceivedACK(int request_id) {
- DataReceivedACK(filter_->child_id(), request_id);
-}
-
-void ResourceDispatcherHostImpl::DataReceivedACK(int child_id,
- int request_id) {
- ResourceLoader* loader = GetLoader(child_id, request_id);
+ ResourceLoader* loader = GetLoader(filter_->child_id(), request_id);
if (!loader)
return;
ResourceRequestInfoImpl* info = loader->GetRequestInfo();
-
- // Decrement the number of pending data messages.
- info->DecrementPendingDataCount();
-
- // If the pending data count was higher than the max, resume the request.
- if (info->pending_data_count() == kMaxPendingDataMessages) {
- // Decrement the pending data count one more time because we also
- // incremented it before pausing the request.
- info->DecrementPendingDataCount();
-
- // Resume the request.
- //
- // TODO(darin): Make the AsyncResourceHandler be responsible for resuming
- // via its controller(). This static_cast is here as a temporary measure.
- //
- static_cast<ResourceController*>(loader)->Resume();
- }
+ if (info->async_handler())
+ info->async_handler()->OnDataReceivedACK();
}
void ResourceDispatcherHostImpl::OnDataDownloadedACK(int request_id) {
@@ -1172,8 +1149,12 @@
return;
}
- loader->OnFollowRedirect(has_new_first_party_for_cookies,
- new_first_party_for_cookies);
+ ResourceRequestInfoImpl* info = loader->GetRequestInfo();
+ if (info->async_handler()) {
+ info->async_handler()->OnFollowRedirect(
+ has_new_first_party_for_cookies,
+ new_first_party_for_cookies);
+ }
}
ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo(
@@ -1288,28 +1269,6 @@
BeginRequestInternal(request.Pass(), handler.Pass());
}
-bool ResourceDispatcherHostImpl::WillSendData(int child_id, int request_id,
- bool* defer) {
- ResourceLoader* loader = GetLoader(child_id, request_id);
- if (!loader) {
- NOTREACHED() << "WillSendData for invalid request";
- return false;
- }
-
- ResourceRequestInfoImpl* info = loader->GetRequestInfo();
-
- info->IncrementPendingDataCount();
- if (info->pending_data_count() > kMaxPendingDataMessages) {
- // We reached the max number of data messages that can be sent to
- // the renderer for a given request. Pause the request and wait for
- // the renderer to start processing them before resuming it.
- *defer = true;
- return false;
- }
-
- return true;
-}
-
void ResourceDispatcherHostImpl::MarkAsTransferredNavigation(
const GlobalRequestID& id) {
GetLoader(id)->MarkAsTransferring();
@@ -1518,6 +1477,9 @@
IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(),
info->GetChildID());
+
+ // A ResourceHandler must not outlive its associated URLRequest.
+ handler.reset();
return;
}

Powered by Google App Engine
This is Rietveld 408576698