OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ipc/ipc_perftest_support.h" | 5 #include "ipc/ipc_perftest_support.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 // message. It assumes each message has one string parameter. When the string | 74 // message. It assumes each message has one string parameter. When the string |
75 // "quit" is sent, it will exit. | 75 // "quit" is sent, it will exit. |
76 class ChannelReflectorListener : public Listener { | 76 class ChannelReflectorListener : public Listener { |
77 public: | 77 public: |
78 ChannelReflectorListener() | 78 ChannelReflectorListener() |
79 : channel_(NULL), | 79 : channel_(NULL), |
80 latency_tracker_("Client messages") { | 80 latency_tracker_("Client messages") { |
81 VLOG(1) << "Client listener up"; | 81 VLOG(1) << "Client listener up"; |
82 } | 82 } |
83 | 83 |
84 virtual ~ChannelReflectorListener() { | 84 ~ChannelReflectorListener() override { |
85 VLOG(1) << "Client listener down"; | 85 VLOG(1) << "Client listener down"; |
86 latency_tracker_.ShowResults(); | 86 latency_tracker_.ShowResults(); |
87 } | 87 } |
88 | 88 |
89 void Init(Channel* channel) { | 89 void Init(Channel* channel) { |
90 DCHECK(!channel_); | 90 DCHECK(!channel_); |
91 channel_ = channel; | 91 channel_ = channel; |
92 } | 92 } |
93 | 93 |
94 virtual bool OnMessageReceived(const Message& message) override { | 94 bool OnMessageReceived(const Message& message) override { |
95 CHECK(channel_); | 95 CHECK(channel_); |
96 | 96 |
97 PickleIterator iter(message); | 97 PickleIterator iter(message); |
98 int64 time_internal; | 98 int64 time_internal; |
99 EXPECT_TRUE(iter.ReadInt64(&time_internal)); | 99 EXPECT_TRUE(iter.ReadInt64(&time_internal)); |
100 int msgid; | 100 int msgid; |
101 EXPECT_TRUE(iter.ReadInt(&msgid)); | 101 EXPECT_TRUE(iter.ReadInt(&msgid)); |
102 std::string payload; | 102 std::string payload; |
103 EXPECT_TRUE(iter.ReadString(&payload)); | 103 EXPECT_TRUE(iter.ReadString(&payload)); |
104 | 104 |
(...skipping 30 matching lines...) Expand all Loading... | |
135 explicit PerformanceChannelListener(const std::string& label) | 135 explicit PerformanceChannelListener(const std::string& label) |
136 : label_(label), | 136 : label_(label), |
137 sender_(NULL), | 137 sender_(NULL), |
138 msg_count_(0), | 138 msg_count_(0), |
139 msg_size_(0), | 139 msg_size_(0), |
140 count_down_(0), | 140 count_down_(0), |
141 latency_tracker_("Server messages") { | 141 latency_tracker_("Server messages") { |
142 VLOG(1) << "Server listener up"; | 142 VLOG(1) << "Server listener up"; |
143 } | 143 } |
144 | 144 |
145 virtual ~PerformanceChannelListener() { | 145 ~PerformanceChannelListener() override { VLOG(1) << "Server listener down"; } |
agl
2014/10/21 17:49:49
Please don't make functions single line just becau
dcheng
2014/10/21 17:57:44
This is a clang-format change. I'm willing to make
| |
146 VLOG(1) << "Server listener down"; | |
147 } | |
148 | 146 |
149 void Init(Sender* sender) { | 147 void Init(Sender* sender) { |
150 DCHECK(!sender_); | 148 DCHECK(!sender_); |
151 sender_ = sender; | 149 sender_ = sender; |
152 } | 150 } |
153 | 151 |
154 // Call this before running the message loop. | 152 // Call this before running the message loop. |
155 void SetTestParams(int msg_count, size_t msg_size) { | 153 void SetTestParams(int msg_count, size_t msg_size) { |
156 DCHECK_EQ(0, count_down_); | 154 DCHECK_EQ(0, count_down_); |
157 msg_count_ = msg_count; | 155 msg_count_ = msg_count; |
158 msg_size_ = msg_size; | 156 msg_size_ = msg_size; |
159 count_down_ = msg_count_; | 157 count_down_ = msg_count_; |
160 payload_ = std::string(msg_size_, 'a'); | 158 payload_ = std::string(msg_size_, 'a'); |
161 } | 159 } |
162 | 160 |
163 virtual bool OnMessageReceived(const Message& message) override { | 161 bool OnMessageReceived(const Message& message) override { |
164 CHECK(sender_); | 162 CHECK(sender_); |
165 | 163 |
166 PickleIterator iter(message); | 164 PickleIterator iter(message); |
167 int64 time_internal; | 165 int64 time_internal; |
168 EXPECT_TRUE(iter.ReadInt64(&time_internal)); | 166 EXPECT_TRUE(iter.ReadInt64(&time_internal)); |
169 int msgid; | 167 int msgid; |
170 EXPECT_TRUE(iter.ReadInt(&msgid)); | 168 EXPECT_TRUE(iter.ReadInt(&msgid)); |
171 std::string reflected_payload; | 169 std::string reflected_payload; |
172 EXPECT_TRUE(iter.ReadString(&reflected_payload)); | 170 EXPECT_TRUE(iter.ReadString(&reflected_payload)); |
173 | 171 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
333 base::MessageLoop::current()->Run(); | 331 base::MessageLoop::current()->Run(); |
334 return 0; | 332 return 0; |
335 } | 333 } |
336 | 334 |
337 scoped_refptr<base::TaskRunner> PingPongTestClient::task_runner() { | 335 scoped_refptr<base::TaskRunner> PingPongTestClient::task_runner() { |
338 return main_message_loop_.message_loop_proxy(); | 336 return main_message_loop_.message_loop_proxy(); |
339 } | 337 } |
340 | 338 |
341 } // namespace test | 339 } // namespace test |
342 } // namespace IPC | 340 } // namespace IPC |
OLD | NEW |