OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } | 184 } |
185 | 185 |
186 int last_request_id() const { return last_request_id_; } | 186 int last_request_id() const { return last_request_id_; } |
187 | 187 |
188 ScopedMessages sent_messages_; | 188 ScopedMessages sent_messages_; |
189 | 189 |
190 private: | 190 private: |
191 std::unique_ptr<ResourceDispatchThrottlerForTest> throttler_; | 191 std::unique_ptr<ResourceDispatchThrottlerForTest> throttler_; |
192 RendererSchedulerForTest scheduler_; | 192 RendererSchedulerForTest scheduler_; |
193 int last_request_id_; | 193 int last_request_id_; |
194 bool flush_scheduled_; | |
195 | 194 |
196 DISALLOW_COPY_AND_ASSIGN(ResourceDispatchThrottlerTest); | 195 DISALLOW_COPY_AND_ASSIGN(ResourceDispatchThrottlerTest); |
197 }; | 196 }; |
198 | 197 |
199 TEST_F(ResourceDispatchThrottlerTest, NotThrottledByDefault) { | 198 TEST_F(ResourceDispatchThrottlerTest, NotThrottledByDefault) { |
200 SetHighPriorityWorkAnticipated(false); | 199 SetHighPriorityWorkAnticipated(false); |
201 for (size_t i = 0; i < kRequestsPerFlush * 2; ++i) { | 200 for (size_t i = 0; i < kRequestsPerFlush * 2; ++i) { |
202 RequestResource(); | 201 RequestResource(); |
203 EXPECT_EQ(i + 1, sent_messages_.size()); | 202 EXPECT_EQ(i + 1, sent_messages_.size()); |
204 } | 203 } |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 EXPECT_EQ(priority_msg.type(), ResourceHostMsg_DidChangePriority::ID); | 404 EXPECT_EQ(priority_msg.type(), ResourceHostMsg_DidChangePriority::ID); |
406 EXPECT_EQ(cancel_msg.type(), ResourceHostMsg_CancelRequest::ID); | 405 EXPECT_EQ(cancel_msg.type(), ResourceHostMsg_CancelRequest::ID); |
407 | 406 |
408 EXPECT_EQ(GetRequestId(request_msg), GetRequestId(priority_msg)); | 407 EXPECT_EQ(GetRequestId(request_msg), GetRequestId(priority_msg)); |
409 EXPECT_EQ(GetRequestId(request_msg) - 1, GetRequestId(cancel_msg)); | 408 EXPECT_EQ(GetRequestId(request_msg) - 1, GetRequestId(cancel_msg)); |
410 } | 409 } |
411 EXPECT_FALSE(FlushScheduled()); | 410 EXPECT_FALSE(FlushScheduled()); |
412 } | 411 } |
413 | 412 |
414 } // namespace content | 413 } // namespace content |
OLD | NEW |