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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include "base/pickle.h" | 7 #include "base/pickle.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "ipc/ipc_message.h" | 9 #include "ipc/ipc_message.h" |
10 #include "ipc/ipc_test_base.h" | 10 #include "ipc/ipc_test_base.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 CHANNEL_CLOSING, | 126 CHANNEL_CLOSING, |
127 FILTER_REMOVED | 127 FILTER_REMOVED |
128 }; | 128 }; |
129 MessageCountFilter() | 129 MessageCountFilter() |
130 : messages_received_(0), | 130 : messages_received_(0), |
131 supported_message_class_(0), | 131 supported_message_class_(0), |
132 is_global_filter_(true), | 132 is_global_filter_(true), |
133 last_filter_event_(NONE), | 133 last_filter_event_(NONE), |
134 message_filtering_enabled_(false) {} | 134 message_filtering_enabled_(false) {} |
135 | 135 |
136 MessageCountFilter(uint32 supported_message_class) | 136 MessageCountFilter(uint32_t supported_message_class) |
137 : messages_received_(0), | 137 : messages_received_(0), |
138 supported_message_class_(supported_message_class), | 138 supported_message_class_(supported_message_class), |
139 is_global_filter_(false), | 139 is_global_filter_(false), |
140 last_filter_event_(NONE), | 140 last_filter_event_(NONE), |
141 message_filtering_enabled_(false) {} | 141 message_filtering_enabled_(false) {} |
142 | 142 |
143 void OnFilterAdded(IPC::Sender* sender) override { | 143 void OnFilterAdded(IPC::Sender* sender) override { |
144 EXPECT_TRUE(sender); | 144 EXPECT_TRUE(sender); |
145 EXPECT_EQ(NONE, last_filter_event_); | 145 EXPECT_EQ(NONE, last_filter_event_); |
146 last_filter_event_ = FILTER_ADDED; | 146 last_filter_event_ = FILTER_ADDED; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 IPC_END_MESSAGE_MAP() | 194 IPC_END_MESSAGE_MAP() |
195 return handled; | 195 return handled; |
196 } | 196 } |
197 | 197 |
198 void OnBadMessage(const BadType& bad_type) { | 198 void OnBadMessage(const BadType& bad_type) { |
199 // Should never be called since IPC wouldn't be deserialized correctly. | 199 // Should never be called since IPC wouldn't be deserialized correctly. |
200 CHECK(false); | 200 CHECK(false); |
201 } | 201 } |
202 | 202 |
203 bool GetSupportedMessageClasses( | 203 bool GetSupportedMessageClasses( |
204 std::vector<uint32>* supported_message_classes) const override { | 204 std::vector<uint32_t>* supported_message_classes) const override { |
205 if (is_global_filter_) | 205 if (is_global_filter_) |
206 return false; | 206 return false; |
207 supported_message_classes->push_back(supported_message_class_); | 207 supported_message_classes->push_back(supported_message_class_); |
208 return true; | 208 return true; |
209 } | 209 } |
210 | 210 |
211 void set_message_filtering_enabled(bool enabled) { | 211 void set_message_filtering_enabled(bool enabled) { |
212 message_filtering_enabled_ = enabled; | 212 message_filtering_enabled_ = enabled; |
213 } | 213 } |
214 | 214 |
215 size_t messages_received() const { return messages_received_; } | 215 size_t messages_received() const { return messages_received_; } |
216 FilterEvent last_filter_event() const { return last_filter_event_; } | 216 FilterEvent last_filter_event() const { return last_filter_event_; } |
217 | 217 |
218 private: | 218 private: |
219 ~MessageCountFilter() override {} | 219 ~MessageCountFilter() override {} |
220 | 220 |
221 size_t messages_received_; | 221 size_t messages_received_; |
222 uint32 supported_message_class_; | 222 uint32_t supported_message_class_; |
223 bool is_global_filter_; | 223 bool is_global_filter_; |
224 | 224 |
225 FilterEvent last_filter_event_; | 225 FilterEvent last_filter_event_; |
226 bool message_filtering_enabled_; | 226 bool message_filtering_enabled_; |
227 }; | 227 }; |
228 | 228 |
229 class IPCChannelProxyTest : public IPCTestBase { | 229 class IPCChannelProxyTest : public IPCTestBase { |
230 public: | 230 public: |
231 IPCChannelProxyTest() {} | 231 IPCChannelProxyTest() {} |
232 ~IPCChannelProxyTest() override {} | 232 ~IPCChannelProxyTest() override {} |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient( | 440 scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient( |
441 IPCTestBase::GetChannelName("ChannelProxyClient"), &listener, nullptr)); | 441 IPCTestBase::GetChannelName("ChannelProxyClient"), &listener, nullptr)); |
442 CHECK(channel->Connect()); | 442 CHECK(channel->Connect()); |
443 listener.Init(channel.get()); | 443 listener.Init(channel.get()); |
444 | 444 |
445 base::MessageLoop::current()->Run(); | 445 base::MessageLoop::current()->Run(); |
446 return 0; | 446 return 0; |
447 } | 447 } |
448 | 448 |
449 } // namespace | 449 } // namespace |
OLD | NEW |