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

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

Issue 12874003: Limit to only 10 image requests per page in ResourceScheduler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 9 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
« no previous file with comments | « content/browser/loader/resource_request_info_impl.h ('k') | content/browser/loader/resource_scheduler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/loader/resource_scheduler.h
diff --git a/content/browser/loader/resource_scheduler.h b/content/browser/loader/resource_scheduler.h
index fa53c5b318f291d1d68a6054f4353d20958552b1..d9711134421c71273abead5be7807bddee68940c 100644
--- a/content/browser/loader/resource_scheduler.h
+++ b/content/browser/loader/resource_scheduler.h
@@ -7,15 +7,14 @@
#include <map>
#include <set>
-#include <vector>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
-#include "base/memory/linked_ptr.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/non_thread_safe.h"
#include "content/common/content_export.h"
-#include "content/public/browser/global_request_id.h"
+#include "net/base/priority_queue.h"
+#include "net/base/request_priority.h"
namespace net {
class URLRequest;
@@ -32,6 +31,11 @@ class ResourceThrottle;
// 2. Notifications for renderer events, such as new tabs, navigation and
// painting.
//
+// These input come from different threads, so they may not be in sync. The UI
+// thread is considered the authority on renderer lifetime, which means some
+// IPCs may be meaningless if they arrive after the UI thread signals a renderer
+// has been deleted.
+//
// The ResourceScheduler tracks many Clients, which should correlate with tabs.
// A client is uniquely identified by its child_id and route_id.
//
@@ -56,12 +60,16 @@ class CONTENT_EXPORT ResourceScheduler : public base::NonThreadSafe {
scoped_ptr<ResourceThrottle> ScheduleRequest(
int child_id, int route_id, net::URLRequest* url_request);
+ // Signals from the UI thread, posted as tasks on the IO thread:
+
// Called when a renderer is created.
void OnClientCreated(int child_id, int route_id);
// Called when a renderer is destroyed.
void OnClientDeleted(int child_id, int route_id);
+ // Signals from IPC messages directly from the renderers:
+
// Called when a client navigates to a new main document.
void OnNavigate(int child_id, int route_id);
@@ -70,32 +78,41 @@ class CONTENT_EXPORT ResourceScheduler : public base::NonThreadSafe {
void OnWillInsertBody(int child_id, int route_id);
private:
+ class RequestQueue;
class ScheduledResourceRequest;
- friend class ScheduledResourceRequest;
struct Client;
typedef int64 ClientId;
typedef std::map<ClientId, Client*> ClientMap;
- typedef std::vector<ScheduledResourceRequest*> RequestQueue;
typedef std::set<ScheduledResourceRequest*> RequestSet;
- struct Client {
- Client();
- ~Client();
-
- bool has_body;
- RequestQueue pending_requests;
- RequestSet in_flight_requests;
- };
-
// Called when a ScheduledResourceRequest is destroyed.
void RemoveRequest(ScheduledResourceRequest* request);
// Unthrottles the |request| and adds it to |client|.
void StartRequest(ScheduledResourceRequest* request, Client* client);
- // Calls StartRequest on all pending requests for |client|.
- void LoadPendingRequests(Client* client);
+ // Update the queue position for |request|, possibly causing it to start
+ // loading.
+ //
+ // Queues are maintained for each priority level. When |request| is
+ // reprioritized, it will move to the end of the queue for that priority
+ // level.
+ void ReprioritizeRequest(ScheduledResourceRequest* request,
+ net::RequestPriority new_priority);
+
+ // Attempts to load any pending requests in |client|, based on the
+ // results of ShouldStartRequest().
+ void LoadAnyStartablePendingRequests(Client* client);
+
+ // Returns the number of requests with priority < LOW that are currently in
+ // flight.
+ size_t GetNumDelayableRequestsInFlight(Client* client) const;
+
+ // Returns true if the request should start. This is the core scheduling
+ // algorithm.
+ bool ShouldStartRequest(ScheduledResourceRequest* request,
+ Client* client) const;
// Returns the client ID for the given |child_id| and |route_id| combo.
ClientId MakeClientId(int child_id, int route_id);
« no previous file with comments | « content/browser/loader/resource_request_info_impl.h ('k') | content/browser/loader/resource_scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698