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

Unified Diff: content/browser/loader/resource_dispatcher_host_impl.h

Issue 1542743002: [RDHI] Refactored blocked_loaders_map_ to key by render frame route id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace FrameTree::ForEach with a for loop Created 4 years, 11 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/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..ef3adfcfe98e0796d7d691094f5c3f2f75090cae 100644
--- a/content/browser/loader/resource_dispatcher_host_impl.h
+++ b/content/browser/loader/resource_dispatcher_host_impl.h
@@ -38,7 +38,9 @@
#include "content/public/browser/download_url_parameters.h"
#include "content/public/browser/global_request_id.h"
#include "content/public/browser/notification_types.h"
+#include "content/public/browser/render_view_host.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,6 +65,7 @@ class ShareableFileReference;
namespace content {
class AppCacheService;
class AsyncRevalidationManager;
+class FrameTree;
class NavigationURLLoaderImplCore;
class ResourceContext;
class ResourceDispatcherHostDelegate;
@@ -77,6 +80,23 @@ 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 +108,21 @@ class CONTENT_EXPORT ResourceDispatcherHostImpl
// hasn't been created yet.
static ResourceDispatcherHostImpl* Get();
+ // This method notifies the RDHI concerning the status of an entire frame
+ // tree. This will correspond to page-level events affecting resource loading.
+ static void NotifyForEachFrame(
+ FrameTree* frame_tree,
+ base::Callback<void(ResourceDispatcherHostImpl*,
+ const GlobalFrameRoutingId&)> frame_callback);
+
+ // This method notifies the RDHI concerning the status of a frame. Consumers
+ // should use the public ResourceDispatcherHost static methods if the
nasko 2016/01/20 22:22:09 nit: Well, this *is* a public static method : ). L
Charlie Harrison 2016/01/21 18:52:55 Done.
+ // RenderFrameHost is available.
+ static void NotifyForRoute(const GlobalFrameRoutingId& routing_id,
+ base::Callback<void(ResourceDispatcherHostImpl*,
+ const GlobalFrameRoutingId&)>
+ frame_callback);
+
// ResourceDispatcherHost implementation:
void SetDelegate(ResourceDispatcherHostDelegate* delegate) override;
void SetAllowCrossOriginAuthPrompt(bool value) override;
@@ -105,8 +140,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 +209,8 @@ class CONTENT_EXPORT ResourceDispatcherHostImpl
return save_file_manager_.get();
}
+ void OnRenderFrameDeleted(const GlobalFrameRoutingId& routing_id);
+
// Called when a RenderViewHost is created.
void OnRenderViewHostCreated(int child_id,
int route_id,
@@ -211,8 +246,15 @@ 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& routing_id);
+
+ // Resumes any blocked request for the specified route id.
+ void ResumeBlockedRequestsForRoute(const GlobalFrameRoutingId& routing_id);
+
// Cancels any blocked request for the specified route id.
- void CancelBlockedRequestsForRoute(int child_id, int route_id);
+ void CancelBlockedRequestsForRoute(const GlobalFrameRoutingId& 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 +420,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 -1.
+ void CancelRequestsForRoute(const GlobalFrameRoutingId& routing_id);
nasko 2016/01/20 22:22:09 nit: global_routing_id? Otherwise it reads as any
Charlie Harrison 2016/01/21 18:52:55 Valid point. For consistency, I'll have to change
// 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,8 +467,7 @@ 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,
+ void ProcessBlockedRequestsForRoute(const GlobalFrameRoutingId& routing_id,
bool cancel_requests);
void OnRequestResource(int routing_id,
@@ -552,7 +594,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

Powered by Google App Engine
This is Rietveld 408576698