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 "components/scheduler/renderer/renderer_scheduler.h" |
10 #include "content/common/resource_messages.h" | 10 #include "content/common/resource_messages.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 void ResourceDispatchThrottler::FlushAll() { | 126 void ResourceDispatchThrottler::FlushAll() { |
127 LogFlush(); | 127 LogFlush(); |
128 if (throttled_messages_.empty()) | 128 if (throttled_messages_.empty()) |
129 return; | 129 return; |
130 | 130 |
131 TRACE_EVENT1("loader", "ResourceDispatchThrottler::FlushAll", | 131 TRACE_EVENT1("loader", "ResourceDispatchThrottler::FlushAll", |
132 "total_throttled_messages", throttled_messages_.size()); | 132 "total_throttled_messages", throttled_messages_.size()); |
133 std::deque<IPC::Message*> throttled_messages; | 133 std::deque<IPC::Message*> throttled_messages; |
134 throttled_messages.swap(throttled_messages_); | 134 throttled_messages.swap(throttled_messages_); |
135 for (auto& message : throttled_messages) | 135 for (auto* message : throttled_messages) |
136 ForwardMessage(message); | 136 ForwardMessage(message); |
137 // There shouldn't be re-entrancy issues when forwarding an IPC, but validate | 137 // There shouldn't be re-entrancy issues when forwarding an IPC, but validate |
138 // as a safeguard. | 138 // as a safeguard. |
139 DCHECK(throttled_messages_.empty()); | 139 DCHECK(throttled_messages_.empty()); |
140 } | 140 } |
141 | 141 |
142 void ResourceDispatchThrottler::LogFlush() { | 142 void ResourceDispatchThrottler::LogFlush() { |
143 sent_requests_since_last_flush_ = 0; | 143 sent_requests_since_last_flush_ = 0; |
144 last_flush_time_ = Now(); | 144 last_flush_time_ = Now(); |
145 } | 145 } |
146 | 146 |
147 bool ResourceDispatchThrottler::ForwardMessage(IPC::Message* msg) { | 147 bool ResourceDispatchThrottler::ForwardMessage(IPC::Message* msg) { |
148 if (IsResourceRequest(*msg)) | 148 if (IsResourceRequest(*msg)) |
149 ++sent_requests_since_last_flush_; | 149 ++sent_requests_since_last_flush_; |
150 | 150 |
151 return proxied_sender_->Send(msg); | 151 return proxied_sender_->Send(msg); |
152 } | 152 } |
153 | 153 |
154 } // namespace content | 154 } // namespace content |
OLD | NEW |