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

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: 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
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..9f31af8cc7716d1fe6f66221f72e91e4effcd8bd 100644
--- a/content/browser/loader/resource_scheduler.h
+++ b/content/browser/loader/resource_scheduler.h
@@ -7,7 +7,6 @@
#include <map>
#include <set>
-#include <vector>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
@@ -16,6 +15,7 @@
#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"
namespace net {
class URLRequest;
@@ -76,7 +76,7 @@ class CONTENT_EXPORT ResourceScheduler : public base::NonThreadSafe {
typedef int64 ClientId;
typedef std::map<ClientId, Client*> ClientMap;
- typedef std::vector<ScheduledResourceRequest*> RequestQueue;
+ typedef net::PriorityQueue<ScheduledResourceRequest*> RequestQueue;
typedef std::set<ScheduledResourceRequest*> RequestSet;
struct Client {
@@ -94,9 +94,22 @@ class CONTENT_EXPORT ResourceScheduler : public base::NonThreadSafe {
// Unthrottles the |request| and adds it to |client|.
void StartRequest(ScheduledResourceRequest* request, Client* client);
- // Calls StartRequest on all pending requests for |client|.
+ // Update the queue position for |request|, possibly causing it to start
+ // loading.
+ void ReprioritizeRequest(ScheduledResourceRequest* request);
willchan no longer on Chromium 2013/03/18 07:30:33 There's some undocumented behavior here, namely th
James Simonsen 2013/03/18 23:50:13 Done. I also thought about the always-at-end thin
+
+ // Attempts to load any pending requests in |client|, based on the
+ // ShouldStartRequest().
void LoadPendingRequests(Client* client);
willchan no longer on Chromium 2013/03/18 07:30:33 Nit: Can we get a better name? I leave it up to yo
James Simonsen 2013/03/18 23:50:13 Done.
+ // Returns the number of requests with priority < LOW that are currently in
+ // flight.
+ int GetNumLowPriorityRequestsInFlight(Client* client);
willchan no longer on Chromium 2013/03/18 07:30:33 Looks like it should be const
James Simonsen 2013/03/18 23:50:13 Done.
+
+ // Returns true if the request should start. This is the core scheduling
+ // algorithm.
+ bool ShouldStartRequest(ScheduledResourceRequest* request, Client* client);
willchan no longer on Chromium 2013/03/18 07:30:33 Looks like it should be const
James Simonsen 2013/03/18 23:50:13 Done.
+
// Returns the client ID for the given |child_id| and |route_id| combo.
ClientId MakeClientId(int child_id, int route_id);

Powered by Google App Engine
This is Rietveld 408576698