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

Issue 10501004: Refactor the guts of ResourceDispatcherHostImpl into a new class named (Closed)

Created:
8 years, 6 months ago by darin (slow to review)
Modified:
8 years, 6 months ago
Reviewers:
jam
CC:
chromium-reviews, mihaip-chromium-reviews_chromium.org, jochen+watch-content_chromium.org, jam, joi+watch-content_chromium.org, Aaron Boodman, darin-cc_chromium.org, rdsmith+dwatch_chromium.org, brettw-cc_chromium.org
Visibility:
Public.

Description

Refactor the guts of ResourceDispatcherHostImpl into a new class named ResourceLoader. This class is responsible for driving the URLRequest (calling Start, Read, and servicing events). This change also generalizes ResourceThrottleController so that it can be used by ResourceHandler implementations to resume or cancel a resource load. The ResourceLoader is a ResourceController. (In a follow-up patch, the BufferedResourceHandler will also become a ResourceController. This will enable us to make the "resume" behavior sane.) The ResourceDispatcherHostImpl now keeps a set of ResourceLoader objects instead of URLRequests. The ResourceLoader owns its URLRequest as well as ResourceHandler (chain). Numerous fields from ResourceRequestInfo become member variables of ResourceLoader because they are only needed by ResourceLoader. This helps cleanup some code. ResourceDispatcherHostImpl is no longer a friend of ResourceRequestInfoImpl, and indeed RRII no longer has any private getter/setters intended for use by RDHI! The ResourceDispatcherHostImpl used to maintain a set of transferred URLRequests. This set is eliminated in favor of just storing a boolean flag on ResourceLoader (is_transferring_). When transferring a request from one RenderView to another, we still replace the ResourceHandler as before, but we keep the ResourceLoader. This means the logic for completing the transfer becomes a member function on ResourceLoader. See ResourceLoader::CompleteTransfer(). NOTE: I left it as future cleanup to improve some of the methods on ResourceLoader that are essentially just copy/pasted from RDHI. For example, I suspect that the new deferred_stage_ member variable will make called_on_response_started_, has_started_reading_, and is_paused_ obsolete. I plan to make these simplifications along with making BufferedResourceHandler implement ResourceController. For now, I'm just trying to minimize changes since this CL is already too big. R=jam@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=142108

Patch Set 1 #

Patch Set 2 : #

Patch Set 3 : #

Patch Set 4 : #

Patch Set 5 : #

Patch Set 6 : #

Patch Set 7 : #

Patch Set 8 : #

Patch Set 9 : #

Patch Set 10 : #

Patch Set 11 : #

Patch Set 12 : #

Patch Set 13 : #

Patch Set 14 : #

Patch Set 15 : #

Patch Set 16 : #

Patch Set 17 : #

Patch Set 18 : #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+1476 lines, -1408 lines) Patch
M chrome/browser/download/download_resource_throttle.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/extensions/user_script_listener.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/extensions/user_script_listener_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 3 chunks +4 lines, -4 lines 0 comments Download
M chrome/browser/renderer_host/offline_resource_throttle.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/renderer_host/safe_browsing_resource_throttle.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +1 line, -1 line 0 comments Download
M content/browser/download/download_manager_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 chunks +2 lines, -5 lines 0 comments Download
M content/browser/download/download_resource_handler.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 chunks +2 lines, -4 lines 0 comments Download
M content/browser/renderer_host/async_resource_handler.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +1 line, -1 line 0 comments Download
M content/browser/renderer_host/buffered_resource_handler.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 chunks +3 lines, -3 lines 0 comments Download
M content/browser/renderer_host/cross_site_resource_handler.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +3 lines, -0 lines 0 comments Download
M content/browser/renderer_host/cross_site_resource_handler.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 5 chunks +15 lines, -8 lines 0 comments Download
M content/browser/renderer_host/layered_resource_handler.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +1 line, -0 lines 0 comments Download
M content/browser/renderer_host/layered_resource_handler.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +11 lines, -0 lines 0 comments Download
M content/browser/renderer_host/redirect_to_file_resource_handler.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 chunks +2 lines, -2 lines 0 comments Download
M content/browser/renderer_host/redirect_to_file_resource_handler.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 7 chunks +17 lines, -10 lines 0 comments Download
M content/browser/renderer_host/resource_dispatcher_host_impl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 12 chunks +41 lines, -130 lines 1 comment Download
M content/browser/renderer_host/resource_dispatcher_host_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 37 chunks +456 lines, -1039 lines 1 comment Download
M content/browser/renderer_host/resource_dispatcher_host_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 chunks +2 lines, -2 lines 0 comments Download
M content/browser/renderer_host/resource_handler.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 3 chunks +11 lines, -0 lines 0 comments Download
A content/browser/renderer_host/resource_handler.cc View 1 2 3 4 5 6 7 1 chunk +13 lines, -0 lines 0 comments Download
A content/browser/renderer_host/resource_loader.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +128 lines, -0 lines 2 comments Download
A content/browser/renderer_host/resource_loader.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +660 lines, -0 lines 0 comments Download
A content/browser/renderer_host/resource_loader_delegate.h View 1 2 3 4 1 chunk +49 lines, -0 lines 0 comments Download
M content/browser/renderer_host/resource_request_info_impl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 8 chunks +2 lines, -97 lines 0 comments Download
M content/browser/renderer_host/resource_request_info_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 6 chunks +5 lines, -31 lines 0 comments Download
M content/browser/renderer_host/throttling_resource_handler.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 chunks +3 lines, -6 lines 0 comments Download
M content/browser/renderer_host/throttling_resource_handler.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 5 chunks +7 lines, -10 lines 0 comments Download
M content/browser/renderer_host/transfer_navigation_resource_throttle.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +3 lines, -2 lines 0 comments Download
M content/browser/ssl/ssl_client_auth_handler.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 3 chunks +4 lines, -5 lines 0 comments Download
M content/content_browser.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 3 chunks +5 lines, -1 line 0 comments Download
M content/public/browser/browser_message_filter.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +3 lines, -3 lines 0 comments Download
M content/public/browser/browser_message_filter.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +4 lines, -4 lines 0 comments Download
A + content/public/browser/resource_controller.h View 1 chunk +7 lines, -7 lines 0 comments Download
M content/public/browser/resource_throttle.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 chunks +8 lines, -8 lines 0 comments Download
D content/public/browser/resource_throttle_controller.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +0 lines, -22 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
darin (slow to review)
Sorry for the huge CL! :-(
8 years, 6 months ago (2012-06-13 18:41:43 UTC) #1
jam
lgtm I assume that the moved parts in resource_loader.cc didn't change, or changed to preserve ...
8 years, 6 months ago (2012-06-14 01:10:22 UTC) #2
darin (slow to review)
8 years, 6 months ago (2012-06-14 06:51:26 UTC) #3
On Wed, Jun 13, 2012 at 6:10 PM, <jam@chromium.org> wrote:

> lgtm
>
> I assume that the moved parts in resource_loader.cc didn't change, or
> changed to
> preserve functionality, as that part was hard to follow. But given green
> try
> runs, I think if there was a problem it would probably be apparent very
> quickly.
>

Right.  I tried doing a "svn cp" of resource_dispatcher_host_impl.cc to
resource_loader.cc, but that doesn't turn out to really help make the patch
easier to read.  Because many variables are no longer under
ResourceRequestInfoImpl, almost all of the lines end up being changed.



>
> nice cleanup!
>
>
> http://codereview.chromium.**org/10501004/diff/39081/**
>
content/browser/renderer_host/**resource_dispatcher_host_impl.**cc<http://codereview.chromium.org/10501004/diff/39081/content/browser/renderer_host/resource_dispatcher_host_impl.cc>
> File content/browser/renderer_host/**resource_dispatcher_host_impl.**cc
> (right):
>
> http://codereview.chromium.**org/10501004/diff/39081/**
> content/browser/renderer_host/**resource_dispatcher_host_impl.**
>
cc#newcode1315<http://codereview.chromium.org/10501004/diff/39081/content/browser/renderer_host/resource_dispatcher_host_impl.cc#newcode1315>
> content/browser/renderer_host/**resource_dispatcher_host_impl.**cc:1315:
> CHECK(loader);
> nit: this isn't needed, it'll crash below which will be just as useful
> of a signal?
>

Done.  Changed to just be GetLoader(id)->Function()


>
> http://codereview.chromium.**org/10501004/diff/39081/**
>
content/browser/renderer_host/**resource_dispatcher_host_impl.**h<http://codereview.chromium.org/10501004/diff/39081/content/browser/renderer_host/resource_dispatcher_host_impl.h>
> File content/browser/renderer_host/**resource_dispatcher_host_impl.**h
> (right):
>
> http://codereview.chromium.**org/10501004/diff/39081/**
> content/browser/renderer_host/**resource_dispatcher_host_impl.**
>
h#newcode90<http://codereview.chromium.org/10501004/diff/39081/content/browser/renderer_host/resource_dispatcher_host_impl.h#newcode90>
> content/browser/renderer_host/**resource_dispatcher_host_impl.**h:90: //
> ResourceLoaderDelegate implementation:
> nit: does this need to be public?
>

Nope, made private.


>
> http://codereview.chromium.**org/10501004/diff/39081/**
>
content/browser/renderer_host/**resource_loader.h<http://codereview.chromium.org/10501004/diff/39081/content/browser/renderer_host/resource_loader.h>
> File content/browser/renderer_host/**resource_loader.h (right):
>
> http://codereview.chromium.**org/10501004/diff/39081/**
>
content/browser/renderer_host/**resource_loader.h#newcode22<http://codereview.chromium.org/10501004/diff/39081/content/browser/renderer_host/resource_loader.h#newcode22>
> content/browser/renderer_host/**resource_loader.h:22: class ResourceLoader
> : public net::URLRequest::Delegate,
> nit: add a comment about what this class is used for
>

Done


>
> http://codereview.chromium.**org/10501004/diff/39081/**
>
content/browser/renderer_host/**resource_loader.h#newcode47<http://codereview.chromium.org/10501004/diff/39081/content/browser/renderer_host/resource_loader.h#newcode47>
> content/browser/renderer_host/**resource_loader.h:47: // IPC message
> handlers:
> nit: these message handlers can be private right? same for the other
> overridden functions?
>

Actually, the message handlers can't.  They are called by RDHI.  I intend
to eliminate them / make them private by using some kind of message
interception system.  The other overridden functions can be private with
one exception.  RDHI needs to call Resume() on the ResourceLoader from
its DataReceivedACK() method.  My plan is to move that code to
AsyncResourceHandler, which would mean that we'd just be calling methods
on controller().  So, I decided to go ahead and make all of these overidden
methods private, and then in that one special place in RDHI, I can just
static_cast to ResourceController in order to call Resume().  I'll add a
TODO
to explain this.



>
>
http://codereview.chromium.**org/10501004/<http://codereview.chromium.org/105...
>

Powered by Google App Engine
This is Rietveld 408576698