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 ~ChannelReflectorListener() override { | 84 virtual ~ChannelReflectorListener() { |
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 bool OnMessageReceived(const Message& message) override { | 94 virtual 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 ~PerformanceChannelListener() override { VLOG(1) << "Server listener down"; } | 145 virtual ~PerformanceChannelListener() { |
| 146 VLOG(1) << "Server listener down"; |
| 147 } |
146 | 148 |
147 void Init(Sender* sender) { | 149 void Init(Sender* sender) { |
148 DCHECK(!sender_); | 150 DCHECK(!sender_); |
149 sender_ = sender; | 151 sender_ = sender; |
150 } | 152 } |
151 | 153 |
152 // Call this before running the message loop. | 154 // Call this before running the message loop. |
153 void SetTestParams(int msg_count, size_t msg_size) { | 155 void SetTestParams(int msg_count, size_t msg_size) { |
154 DCHECK_EQ(0, count_down_); | 156 DCHECK_EQ(0, count_down_); |
155 msg_count_ = msg_count; | 157 msg_count_ = msg_count; |
156 msg_size_ = msg_size; | 158 msg_size_ = msg_size; |
157 count_down_ = msg_count_; | 159 count_down_ = msg_count_; |
158 payload_ = std::string(msg_size_, 'a'); | 160 payload_ = std::string(msg_size_, 'a'); |
159 } | 161 } |
160 | 162 |
161 bool OnMessageReceived(const Message& message) override { | 163 virtual bool OnMessageReceived(const Message& message) override { |
162 CHECK(sender_); | 164 CHECK(sender_); |
163 | 165 |
164 PickleIterator iter(message); | 166 PickleIterator iter(message); |
165 int64 time_internal; | 167 int64 time_internal; |
166 EXPECT_TRUE(iter.ReadInt64(&time_internal)); | 168 EXPECT_TRUE(iter.ReadInt64(&time_internal)); |
167 int msgid; | 169 int msgid; |
168 EXPECT_TRUE(iter.ReadInt(&msgid)); | 170 EXPECT_TRUE(iter.ReadInt(&msgid)); |
169 std::string reflected_payload; | 171 std::string reflected_payload; |
170 EXPECT_TRUE(iter.ReadString(&reflected_payload)); | 172 EXPECT_TRUE(iter.ReadString(&reflected_payload)); |
171 | 173 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 base::MessageLoop::current()->Run(); | 333 base::MessageLoop::current()->Run(); |
332 return 0; | 334 return 0; |
333 } | 335 } |
334 | 336 |
335 scoped_refptr<base::TaskRunner> PingPongTestClient::task_runner() { | 337 scoped_refptr<base::TaskRunner> PingPongTestClient::task_runner() { |
336 return main_message_loop_.message_loop_proxy(); | 338 return main_message_loop_.message_loop_proxy(); |
337 } | 339 } |
338 | 340 |
339 } // namespace test | 341 } // namespace test |
340 } // namespace IPC | 342 } // namespace IPC |
OLD | NEW |