 Chromium Code Reviews
 Chromium Code Reviews Issue 393163003:
  Add coalescing timer to ResourceScheduler. CL 2 from BUG=128035.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@rsblank
    
  
    Issue 393163003:
  Add coalescing timer to ResourceScheduler. CL 2 from BUG=128035.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@rsblank| Index: content/browser/loader/resource_scheduler.h | 
| diff --git a/content/browser/loader/resource_scheduler.h b/content/browser/loader/resource_scheduler.h | 
| index b445a6818fddec1e7726ff9b16c32ad5773d205d..4e4a81856d2a383a4fdbb615ec3b39157df1e7fa 100644 | 
| --- a/content/browser/loader/resource_scheduler.h | 
| +++ b/content/browser/loader/resource_scheduler.h | 
| @@ -12,6 +12,7 @@ | 
| #include "base/compiler_specific.h" | 
| #include "base/memory/scoped_ptr.h" | 
| #include "base/threading/non_thread_safe.h" | 
| +#include "base/timer/timer.h" | 
| #include "content/common/content_export.h" | 
| #include "net/base/priority_queue.h" | 
| #include "net/base/request_priority.h" | 
| @@ -69,6 +70,13 @@ class CONTENT_EXPORT ResourceScheduler : public base::NonThreadSafe { | 
| ResourceScheduler(); | 
| ~ResourceScheduler(); | 
| + // Use a mock timer when testing. | 
| + void set_timer_for_testing(scoped_ptr<base::Timer> timer) { | 
| + DCHECK(timer); | 
| 
mmenke
2014/07/25 16:33:27
Probably shouldn't have DCHECKs in header files.
 | 
| + coalescing_timer_.reset(); | 
| + coalescing_timer_.reset(timer.release()); | 
| 
mmenke
2014/07/25 16:33:27
Don't need two calls.
coalescing_timer_.reset(tim
 | 
| + } | 
| + | 
| // TODO(aiolos): Remove when throttling and coalescing have landed | 
| void SetThrottleOptionsForTesting(bool should_throttle, bool should_coalesce); | 
| @@ -136,16 +144,26 @@ class CONTENT_EXPORT ResourceScheduler : public base::NonThreadSafe { | 
| // Called when a ScheduledResourceRequest is destroyed. | 
| void RemoveRequest(ScheduledResourceRequest* request); | 
| - // These Calls may update the ThrottleState of all clients, and have the | 
| - // potential to be re-entarant. | 
| + // These calls may update the ThrottleState of all clients, and have the | 
| + // potential to be re-entrant. | 
| // Called when a Client newly becomes active loading. | 
| - void DecrementActiveClientsLoading(); | 
| - // Caled when a Client stops being active loading. | 
| void IncrementActiveClientsLoading(); | 
| + // Called when an active and loading Client either completes loading or | 
| + // becomes inactive. | 
| + void DecrementActiveClientsLoading(); | 
| + | 
| + void OnLoadingActiveClientsStateChangedForAllClients(); | 
| + | 
| + size_t CountActiveClientsLoading() const; | 
| + | 
| + // Called when a Client becomes coalesced. | 
| + void IncrementCoalescedClients(); | 
| + // Called when a client stops being coalesced. | 
| + void DecrementCoalescedClients(); | 
| - void OnLoadingActiveClientsStateChanged(); | 
| + void LoadRequestsForAllCoalescedClients(); | 
| - size_t CountActiveClientsLoading(); | 
| + size_t CountCoalescedClients() const; | 
| // Update the queue position for |request|, possibly causing it to start | 
| // loading. | 
| @@ -167,6 +185,9 @@ class CONTENT_EXPORT ResourceScheduler : public base::NonThreadSafe { | 
| bool should_throttle_; | 
| ClientMap client_map_; | 
| size_t active_clients_loading_; | 
| + size_t coalesced_clients_; | 
| + /* This is a repeating timer to initiate requests on COALESCED Clients. */ | 
| 
mmenke
2014/07/25 16:33:27
nit:  Generally should use C++-style comments.
 | 
| + scoped_ptr<base::Timer> coalescing_timer_; | 
| RequestSet unowned_requests_; | 
| }; |