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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 CHECK(IPC::ReadParam(msg, &iter, &routing_id)); | 181 CHECK(IPC::ReadParam(msg, &iter, &routing_id)); |
182 CHECK(IPC::ReadParam(msg, &iter, &request_id)); | 182 CHECK(IPC::ReadParam(msg, &iter, &request_id)); |
183 return request_id; | 183 return request_id; |
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 scoped_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_; | 194 bool flush_scheduled_; |
195 | 195 |
196 DISALLOW_COPY_AND_ASSIGN(ResourceDispatchThrottlerTest); | 196 DISALLOW_COPY_AND_ASSIGN(ResourceDispatchThrottlerTest); |
197 }; | 197 }; |
198 | 198 |
199 TEST_F(ResourceDispatchThrottlerTest, NotThrottledByDefault) { | 199 TEST_F(ResourceDispatchThrottlerTest, NotThrottledByDefault) { |
200 SetHighPriorityWorkAnticipated(false); | 200 SetHighPriorityWorkAnticipated(false); |
201 for (size_t i = 0; i < kRequestsPerFlush * 2; ++i) { | 201 for (size_t i = 0; i < kRequestsPerFlush * 2; ++i) { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 EXPECT_EQ(priority_msg.type(), ResourceHostMsg_DidChangePriority::ID); | 405 EXPECT_EQ(priority_msg.type(), ResourceHostMsg_DidChangePriority::ID); |
406 EXPECT_EQ(cancel_msg.type(), ResourceHostMsg_CancelRequest::ID); | 406 EXPECT_EQ(cancel_msg.type(), ResourceHostMsg_CancelRequest::ID); |
407 | 407 |
408 EXPECT_EQ(GetRequestId(request_msg), GetRequestId(priority_msg)); | 408 EXPECT_EQ(GetRequestId(request_msg), GetRequestId(priority_msg)); |
409 EXPECT_EQ(GetRequestId(request_msg) - 1, GetRequestId(cancel_msg)); | 409 EXPECT_EQ(GetRequestId(request_msg) - 1, GetRequestId(cancel_msg)); |
410 } | 410 } |
411 EXPECT_FALSE(FlushScheduled()); | 411 EXPECT_FALSE(FlushScheduled()); |
412 } | 412 } |
413 | 413 |
414 } // namespace content | 414 } // namespace content |
OLD | NEW |