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 "mojo/system/raw_channel.h" | 5 #include "mojo/system/raw_channel.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 namespace system { | 33 namespace system { |
34 namespace { | 34 namespace { |
35 | 35 |
36 scoped_ptr<MessageInTransit> MakeTestMessage(uint32_t num_bytes) { | 36 scoped_ptr<MessageInTransit> MakeTestMessage(uint32_t num_bytes) { |
37 std::vector<unsigned char> bytes(num_bytes, 0); | 37 std::vector<unsigned char> bytes(num_bytes, 0); |
38 for (size_t i = 0; i < num_bytes; i++) | 38 for (size_t i = 0; i < num_bytes; i++) |
39 bytes[i] = static_cast<unsigned char>(i + num_bytes); | 39 bytes[i] = static_cast<unsigned char>(i + num_bytes); |
40 return make_scoped_ptr( | 40 return make_scoped_ptr( |
41 new MessageInTransit(MessageInTransit::kTypeMessagePipeEndpoint, | 41 new MessageInTransit(MessageInTransit::kTypeMessagePipeEndpoint, |
42 MessageInTransit::kSubtypeMessagePipeEndpointData, | 42 MessageInTransit::kSubtypeMessagePipeEndpointData, |
43 num_bytes, 0, bytes.empty() ? NULL : &bytes[0])); | 43 num_bytes, bytes.empty() ? NULL : &bytes[0])); |
44 } | 44 } |
45 | 45 |
46 bool CheckMessageData(const void* bytes, uint32_t num_bytes) { | 46 bool CheckMessageData(const void* bytes, uint32_t num_bytes) { |
47 const unsigned char* b = static_cast<const unsigned char*>(bytes); | 47 const unsigned char* b = static_cast<const unsigned char*>(bytes); |
48 for (uint32_t i = 0; i < num_bytes; i++) { | 48 for (uint32_t i = 0; i < num_bytes; i++) { |
49 if (b[i] != static_cast<unsigned char>(i + num_bytes)) | 49 if (b[i] != static_cast<unsigned char>(i + num_bytes)) |
50 return false; | 50 return false; |
51 } | 51 } |
52 return true; | 52 return true; |
53 } | 53 } |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 | 669 |
670 EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1))); | 670 EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1))); |
671 | 671 |
672 // Wait for the delegate, which will shut the |RawChannel| down. | 672 // Wait for the delegate, which will shut the |RawChannel| down. |
673 delegate.Wait(); | 673 delegate.Wait(); |
674 } | 674 } |
675 | 675 |
676 } // namespace | 676 } // namespace |
677 } // namespace system | 677 } // namespace system |
678 } // namespace mojo | 678 } // namespace mojo |
OLD | NEW |