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> |
| 8 #include <stdint.h> |
| 9 |
| 10 #include "base/macros.h" |
7 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
8 #include "content/common/resource_messages.h" | 12 #include "content/common/resource_messages.h" |
9 #include "content/test/fake_renderer_scheduler.h" | 13 #include "content/test/fake_renderer_scheduler.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
11 | 15 |
12 namespace content { | 16 namespace content { |
13 namespace { | 17 namespace { |
14 | 18 |
15 const uint32 kRequestsPerFlush = 4; | 19 const uint32_t kRequestsPerFlush = 4; |
16 const double kFlushPeriodSeconds = 1.f / 60; | 20 const double kFlushPeriodSeconds = 1.f / 60; |
17 const int kRoutingId = 1; | 21 const int kRoutingId = 1; |
18 | 22 |
19 typedef ScopedVector<IPC::Message> ScopedMessages; | 23 typedef ScopedVector<IPC::Message> ScopedMessages; |
20 | 24 |
21 int GetRequestId(const IPC::Message& msg) { | 25 int GetRequestId(const IPC::Message& msg) { |
22 int request_id = -1; | 26 int request_id = -1; |
23 switch (msg.type()) { | 27 switch (msg.type()) { |
24 case ResourceHostMsg_RequestResource::ID: { | 28 case ResourceHostMsg_RequestResource::ID: { |
25 base::PickleIterator iter(msg); | 29 base::PickleIterator iter(msg); |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 EXPECT_EQ(priority_msg.type(), ResourceHostMsg_DidChangePriority::ID); | 365 EXPECT_EQ(priority_msg.type(), ResourceHostMsg_DidChangePriority::ID); |
362 EXPECT_EQ(cancel_msg.type(), ResourceHostMsg_CancelRequest::ID); | 366 EXPECT_EQ(cancel_msg.type(), ResourceHostMsg_CancelRequest::ID); |
363 | 367 |
364 EXPECT_EQ(GetRequestId(request_msg), GetRequestId(priority_msg)); | 368 EXPECT_EQ(GetRequestId(request_msg), GetRequestId(priority_msg)); |
365 EXPECT_EQ(GetRequestId(request_msg) - 1, GetRequestId(cancel_msg)); | 369 EXPECT_EQ(GetRequestId(request_msg) - 1, GetRequestId(cancel_msg)); |
366 } | 370 } |
367 EXPECT_FALSE(FlushScheduled()); | 371 EXPECT_FALSE(FlushScheduled()); |
368 } | 372 } |
369 | 373 |
370 } // namespace content | 374 } // namespace content |
OLD | NEW |