Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: content/renderer/scheduler/resource_dispatch_throttler_unittest.cc

Issue 2118903002: scheduler: Move the Blink scheduler into Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/scheduler/resource_dispatch_throttler.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
12 #include "content/common/resource_messages.h" 12 #include "content/common/resource_messages.h"
13 #include "content/common/resource_request.h" 13 #include "content/common/resource_request.h"
14 #include "content/test/fake_renderer_scheduler.h"
15 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/WebKit/public/platform/scheduler/test/fake_renderer_schedu ler.h"
16 16
17 namespace content { 17 namespace content {
18 namespace { 18 namespace {
19 19
20 const uint32_t kRequestsPerFlush = 4; 20 const uint32_t kRequestsPerFlush = 4;
21 const double kFlushPeriodSeconds = 1.f / 60; 21 const double kFlushPeriodSeconds = 1.f / 60;
22 const int kRoutingId = 1; 22 const int kRoutingId = 1;
23 23
24 typedef ScopedVector<IPC::Message> ScopedMessages; 24 typedef ScopedVector<IPC::Message> ScopedMessages;
25 25
(...skipping 14 matching lines...) Expand all
40 NOTREACHED() << "Invalid id for resource message."; 40 NOTREACHED() << "Invalid id for resource message.";
41 break; 41 break;
42 42
43 default: 43 default:
44 NOTREACHED() << "Invalid message for resource throttling."; 44 NOTREACHED() << "Invalid message for resource throttling.";
45 break; 45 break;
46 } 46 }
47 return request_id; 47 return request_id;
48 } 48 }
49 49
50 class RendererSchedulerForTest : public FakeRendererScheduler { 50 class RendererSchedulerForTest
51 : public blink::scheduler::FakeRendererScheduler {
51 public: 52 public:
52 RendererSchedulerForTest() : high_priority_work_anticipated_(false) {} 53 RendererSchedulerForTest() : high_priority_work_anticipated_(false) {}
53 ~RendererSchedulerForTest() override {} 54 ~RendererSchedulerForTest() override {}
54 55
55 // RendererScheduler implementation: 56 // RendererScheduler implementation:
56 bool IsHighPriorityWorkAnticipated() override { 57 bool IsHighPriorityWorkAnticipated() override {
57 return high_priority_work_anticipated_; 58 return high_priority_work_anticipated_;
58 } 59 }
59 60
60 void set_high_priority_work_anticipated(bool anticipated) { 61 void set_high_priority_work_anticipated(bool anticipated) {
61 high_priority_work_anticipated_ = anticipated; 62 high_priority_work_anticipated_ = anticipated;
62 } 63 }
63 64
64 private: 65 private:
65 bool high_priority_work_anticipated_; 66 bool high_priority_work_anticipated_;
66 }; 67 };
67 68
68 } // namespace 69 } // namespace
69 70
70 class ResourceDispatchThrottlerForTest : public ResourceDispatchThrottler { 71 class ResourceDispatchThrottlerForTest : public ResourceDispatchThrottler {
71 public: 72 public:
72 ResourceDispatchThrottlerForTest(IPC::Sender* sender, 73 ResourceDispatchThrottlerForTest(
73 scheduler::RendererScheduler* scheduler) 74 IPC::Sender* sender,
75 blink::scheduler::RendererScheduler* scheduler)
74 : ResourceDispatchThrottler( 76 : ResourceDispatchThrottler(
75 sender, 77 sender,
76 scheduler, 78 scheduler,
77 base::TimeDelta::FromSecondsD(kFlushPeriodSeconds), 79 base::TimeDelta::FromSecondsD(kFlushPeriodSeconds),
78 kRequestsPerFlush), 80 kRequestsPerFlush),
79 now_(base::TimeTicks() + base::TimeDelta::FromDays(1)), 81 now_(base::TimeTicks() + base::TimeDelta::FromDays(1)),
80 flush_scheduled_(false) {} 82 flush_scheduled_(false) {}
81 ~ResourceDispatchThrottlerForTest() override {} 83 ~ResourceDispatchThrottlerForTest() override {}
82 84
83 void Advance(base::TimeDelta delta) { now_ += delta; } 85 void Advance(base::TimeDelta delta) { now_ += delta; }
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 EXPECT_EQ(priority_msg.type(), ResourceHostMsg_DidChangePriority::ID); 407 EXPECT_EQ(priority_msg.type(), ResourceHostMsg_DidChangePriority::ID);
406 EXPECT_EQ(cancel_msg.type(), ResourceHostMsg_CancelRequest::ID); 408 EXPECT_EQ(cancel_msg.type(), ResourceHostMsg_CancelRequest::ID);
407 409
408 EXPECT_EQ(GetRequestId(request_msg), GetRequestId(priority_msg)); 410 EXPECT_EQ(GetRequestId(request_msg), GetRequestId(priority_msg));
409 EXPECT_EQ(GetRequestId(request_msg) - 1, GetRequestId(cancel_msg)); 411 EXPECT_EQ(GetRequestId(request_msg) - 1, GetRequestId(cancel_msg));
410 } 412 }
411 EXPECT_FALSE(FlushScheduled()); 413 EXPECT_FALSE(FlushScheduled());
412 } 414 }
413 415
414 } // namespace content 416 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/scheduler/resource_dispatch_throttler.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698