OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_test_sink.h" | 5 #include "ipc/ipc_test_sink.h" |
6 | 6 |
7 #include "ipc/ipc_listener.h" | 7 #include "ipc/ipc_listener.h" |
8 #include "ipc/ipc_message.h" | 8 #include "ipc/ipc_message.h" |
9 | 9 |
10 namespace IPC { | 10 namespace IPC { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 void TestSink::ClearMessages() { | 56 void TestSink::ClearMessages() { |
57 messages_.clear(); | 57 messages_.clear(); |
58 } | 58 } |
59 | 59 |
60 const Message* TestSink::GetMessageAt(size_t index) const { | 60 const Message* TestSink::GetMessageAt(size_t index) const { |
61 if (index >= messages_.size()) | 61 if (index >= messages_.size()) |
62 return NULL; | 62 return NULL; |
63 return &messages_[index]; | 63 return &messages_[index]; |
64 } | 64 } |
65 | 65 |
66 const Message* TestSink::GetFirstMessageMatching(uint32 id) const { | 66 const Message* TestSink::GetFirstMessageMatching(uint32_t id) const { |
67 for (size_t i = 0; i < messages_.size(); i++) { | 67 for (size_t i = 0; i < messages_.size(); i++) { |
68 if (messages_[i].type() == id) | 68 if (messages_[i].type() == id) |
69 return &messages_[i]; | 69 return &messages_[i]; |
70 } | 70 } |
71 return NULL; | 71 return NULL; |
72 } | 72 } |
73 | 73 |
74 const Message* TestSink::GetUniqueMessageMatching(uint32 id) const { | 74 const Message* TestSink::GetUniqueMessageMatching(uint32_t id) const { |
75 size_t found_index = 0; | 75 size_t found_index = 0; |
76 size_t found_count = 0; | 76 size_t found_count = 0; |
77 for (size_t i = 0; i < messages_.size(); i++) { | 77 for (size_t i = 0; i < messages_.size(); i++) { |
78 if (messages_[i].type() == id) { | 78 if (messages_[i].type() == id) { |
79 found_count++; | 79 found_count++; |
80 found_index = i; | 80 found_index = i; |
81 } | 81 } |
82 } | 82 } |
83 if (found_count != 1) | 83 if (found_count != 1) |
84 return NULL; // Didn't find a unique one. | 84 return NULL; // Didn't find a unique one. |
(...skipping 16 matching lines...) Expand all Loading... |
101 } | 101 } |
102 | 102 |
103 base::ScopedFD TestSink::TakeClientFileDescriptor() { | 103 base::ScopedFD TestSink::TakeClientFileDescriptor() { |
104 NOTREACHED(); | 104 NOTREACHED(); |
105 return base::ScopedFD(); | 105 return base::ScopedFD(); |
106 } | 106 } |
107 | 107 |
108 #endif // defined(OS_POSIX) && !defined(OS_NACL) | 108 #endif // defined(OS_POSIX) && !defined(OS_NACL) |
109 | 109 |
110 } // namespace IPC | 110 } // namespace IPC |
OLD | NEW |