| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/scheduler/resource_dispatch_throttler.h" | 5 #include "content/renderer/scheduler/resource_dispatch_throttler.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "components/scheduler/renderer/renderer_scheduler.h" |
| 9 #include "content/common/resource_messages.h" | 10 #include "content/common/resource_messages.h" |
| 10 #include "content/renderer/scheduler/renderer_scheduler.h" | |
| 11 #include "ipc/ipc_message_macros.h" | 11 #include "ipc/ipc_message_macros.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 bool IsResourceRequest(const IPC::Message& msg) { | 16 bool IsResourceRequest(const IPC::Message& msg) { |
| 17 return msg.type() == ResourceHostMsg_RequestResource::ID; | 17 return msg.type() == ResourceHostMsg_RequestResource::ID; |
| 18 } | 18 } |
| 19 | 19 |
| 20 } // namespace | 20 } // namespace |
| 21 | 21 |
| 22 ResourceDispatchThrottler::ResourceDispatchThrottler( | 22 ResourceDispatchThrottler::ResourceDispatchThrottler( |
| 23 IPC::Sender* proxied_sender, | 23 IPC::Sender* proxied_sender, |
| 24 RendererScheduler* scheduler, | 24 scheduler::RendererScheduler* scheduler, |
| 25 base::TimeDelta flush_period, | 25 base::TimeDelta flush_period, |
| 26 uint32 max_requests_per_flush) | 26 uint32 max_requests_per_flush) |
| 27 : proxied_sender_(proxied_sender), | 27 : proxied_sender_(proxied_sender), |
| 28 scheduler_(scheduler), | 28 scheduler_(scheduler), |
| 29 flush_period_(flush_period), | 29 flush_period_(flush_period), |
| 30 max_requests_per_flush_(max_requests_per_flush), | 30 max_requests_per_flush_(max_requests_per_flush), |
| 31 flush_timer_( | 31 flush_timer_( |
| 32 FROM_HERE, | 32 FROM_HERE, |
| 33 flush_period_, | 33 flush_period_, |
| 34 base::Bind(&ResourceDispatchThrottler::Flush, base::Unretained(this)), | 34 base::Bind(&ResourceDispatchThrottler::Flush, base::Unretained(this)), |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 bool ResourceDispatchThrottler::ForwardMessage(IPC::Message* msg) { | 138 bool ResourceDispatchThrottler::ForwardMessage(IPC::Message* msg) { |
| 139 if (IsResourceRequest(*msg)) { | 139 if (IsResourceRequest(*msg)) { |
| 140 last_sent_request_time_ = Now(); | 140 last_sent_request_time_ = Now(); |
| 141 ++sent_requests_since_last_flush_; | 141 ++sent_requests_since_last_flush_; |
| 142 } | 142 } |
| 143 return proxied_sender_->Send(msg); | 143 return proxied_sender_->Send(msg); |
| 144 } | 144 } |
| 145 | 145 |
| 146 } // namespace content | 146 } // namespace content |
| OLD | NEW |