| Index: content/browser/renderer_host/resource_dispatcher_host_impl.cc
|
| ===================================================================
|
| --- content/browser/renderer_host/resource_dispatcher_host_impl.cc (revision 142108)
|
| +++ 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.
|
| @@ -933,22 +929,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);
|
|
|
| @@ -989,6 +969,22 @@
|
| upload_size = request_data.upload_data->GetContentLengthSync();
|
| }
|
|
|
| + // Construct the IPC resource handler.
|
| + scoped_ptr<ResourceHandler> handler;
|
| + 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
|
| @@ -999,8 +995,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.
|
| @@ -1084,33 +1080,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) {
|
| @@ -1174,8 +1150,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(
|
| @@ -1290,28 +1270,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();
|
|
|