Index: content/browser/loader/resource_dispatcher_host_impl.h |
diff --git a/content/browser/loader/resource_dispatcher_host_impl.h b/content/browser/loader/resource_dispatcher_host_impl.h |
index a64f34a377eefdd63a8b6bc74e32350945c27d70..2ac2b63282424f430ef01b84270f6e29abf3ad52 100644 |
--- a/content/browser/loader/resource_dispatcher_host_impl.h |
+++ b/content/browser/loader/resource_dispatcher_host_impl.h |
@@ -39,6 +39,7 @@ |
#include "content/public/browser/global_request_id.h" |
#include "content/public/browser/notification_types.h" |
#include "content/public/browser/resource_dispatcher_host.h" |
+#include "content/public/browser/web_contents_observer.h" |
#include "content/public/common/resource_type.h" |
#include "ipc/ipc_message.h" |
#include "net/base/request_priority.h" |
@@ -63,7 +64,9 @@ class ShareableFileReference; |
namespace content { |
class AppCacheService; |
class AsyncRevalidationManager; |
+class FrameTree; |
class NavigationURLLoaderImplCore; |
+class RenderFrameHostImpl; |
class ResourceContext; |
class ResourceDispatcherHostDelegate; |
class ResourceMessageDelegate; |
@@ -77,6 +80,22 @@ struct DownloadSaveInfo; |
struct NavigationRequestInfo; |
struct Referrer; |
+// This class is responsible for notifying the IO thread (specifically, the |
+// ResourceDispatcherHostImpl) of frame events. It has an interace for callers |
+// to use and also sends notifications on WebContentsObserver events. All |
+// methods (static or class) will be called from the UI thread and post to the |
+// IO thread. |
+// TODO(csharrison): Add methods tracking visibility and audio changes, to |
+// propogate to the ResourceScheduler. |
+class LoaderIOThreadNotifier : public WebContentsObserver { |
+ public: |
+ explicit LoaderIOThreadNotifier(WebContents* web_contents); |
+ ~LoaderIOThreadNotifier() override; |
+ |
+ // content::WebContentsObserver: |
+ void RenderFrameDeleted(RenderFrameHost* render_frame_host) override; |
+}; |
+ |
class CONTENT_EXPORT ResourceDispatcherHostImpl |
: public ResourceDispatcherHost, |
public ResourceLoaderDelegate { |
@@ -88,6 +107,26 @@ class CONTENT_EXPORT ResourceDispatcherHostImpl |
// hasn't been created yet. |
static ResourceDispatcherHostImpl* Get(); |
+ // The following static methods should all be called from the UI thread. |
+ |
+ // Resumes requests for a given render frame routing id. This will only resume |
+ // requests for a single frame. |
+ static void ResumeBlockedRequestsForRouteOnUI( |
Randy Smith (Not in Mondays)
2016/02/01 21:19:20
Nit: For consistency, I'd either name them all wit
|
+ const GlobalFrameRoutingId& global_routing_id); |
+ |
+ // Blocks (and does not start) all requests for the frame tree identified by |
nasko
2016/02/02 21:26:29
nit: Change "frame tree" with "frame and its subfr
Charlie Harrison
2016/02/02 21:44:22
Done.
|
+ // |root_frame_host|. |
+ static void BlockRequestsForFrames(RenderFrameHost* root_frame_host); |
+ |
+ // Resumes any blocked requests for the specified frame tree identified by |
+ // |root_frame_host|. |
+ static void ResumeBlockedRequestsForFrames(RenderFrameHost* root_frame_host); |
+ |
+ // Cancels any blocked request for the frame tree identified by |
+ // |root_frame_host|. |
+ static void CancelBlockedRequestsForFrames( |
+ RenderFrameHostImpl* root_frame_host); |
+ |
// ResourceDispatcherHost implementation: |
void SetDelegate(ResourceDispatcherHostDelegate* delegate) override; |
void SetAllowCrossOriginAuthPrompt(bool value) override; |
@@ -105,8 +144,6 @@ class CONTENT_EXPORT ResourceDispatcherHostImpl |
uint32_t download_id, |
const DownloadStartedCallback& started_callback) override; |
void ClearLoginDelegateForRequest(net::URLRequest* request) override; |
- void BlockRequestsForRoute(int child_id, int route_id) override; |
- void ResumeBlockedRequestsForRoute(int child_id, int route_id) override; |
// Puts the resource dispatcher host in an inactive state (unable to begin |
// new requests). Cancels all pending requests. |
@@ -176,6 +213,8 @@ class CONTENT_EXPORT ResourceDispatcherHostImpl |
return save_file_manager_.get(); |
} |
+ void OnRenderFrameDeleted(const GlobalFrameRoutingId& global_routing_id); |
+ |
// Called when a RenderViewHost is created. |
void OnRenderViewHostCreated(int child_id, |
int route_id, |
@@ -211,8 +250,17 @@ class CONTENT_EXPORT ResourceDispatcherHostImpl |
void RemovePendingRequest(int child_id, int request_id); |
+ // Causes all new requests for the route identified by |routing_id| to be |
+ // blocked (not being started) until ResumeBlockedRequestsForRoute is called. |
+ void BlockRequestsForRoute(const GlobalFrameRoutingId& global_routing_id); |
+ |
+ // Resumes any blocked request for the specified route id. |
+ void ResumeBlockedRequestsForRoute( |
+ const GlobalFrameRoutingId& global_routing_id); |
+ |
// Cancels any blocked request for the specified route id. |
- void CancelBlockedRequestsForRoute(int child_id, int route_id); |
+ void CancelBlockedRequestsForRoute( |
+ const GlobalFrameRoutingId& global_routing_id); |
// Maintains a collection of temp files created in support of |
// the download_to_file capability. Used to grant access to the |
@@ -378,8 +426,9 @@ class CONTENT_EXPORT ResourceDispatcherHostImpl |
static int CalculateApproximateMemoryCost(net::URLRequest* request); |
// Force cancels any pending requests for the given route id. This method |
- // acts like CancelRequestsForProcess when route_id is -1. |
- void CancelRequestsForRoute(int child_id, int route_id); |
+ // acts like CancelRequestsForProcess when the |route_id| member of |
+ // |routing_id| is MSG_ROUTING_NONE. |
+ void CancelRequestsForRoute(const GlobalFrameRoutingId& global_routing_id); |
// The list of all requests that we have pending. This list is not really |
// optimized, and assumes that we have relatively few requests pending at once |
@@ -424,9 +473,9 @@ class CONTENT_EXPORT ResourceDispatcherHostImpl |
void UpdateLoadInfo(); |
// Resumes or cancels (if |cancel_requests| is true) any blocked requests. |
- void ProcessBlockedRequestsForRoute(int child_id, |
- int route_id, |
- bool cancel_requests); |
+ void ProcessBlockedRequestsForRoute( |
+ const GlobalFrameRoutingId& global_routing_id, |
+ bool cancel_requests); |
void OnRequestResource(int routing_id, |
int request_id, |
@@ -552,7 +601,7 @@ class CONTENT_EXPORT ResourceDispatcherHostImpl |
using BlockedLoadersList = std::vector<scoped_ptr<ResourceLoader>>; |
using BlockedLoadersMap = |
- std::map<GlobalRoutingID, scoped_ptr<BlockedLoadersList>>; |
+ std::map<GlobalFrameRoutingId, scoped_ptr<BlockedLoadersList>>; |
BlockedLoadersMap blocked_loaders_map_; |
// Maps the child_ids to the approximate number of bytes |