| 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/edk/system/raw_channel.h" | 5 #include "mojo/edk/system/raw_channel.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 bool CheckMessageData(const void* bytes, uint32_t num_bytes) { | 52 bool CheckMessageData(const void* bytes, uint32_t num_bytes) { |
| 53 const unsigned char* b = static_cast<const unsigned char*>(bytes); | 53 const unsigned char* b = static_cast<const unsigned char*>(bytes); |
| 54 for (uint32_t i = 0; i < num_bytes; i++) { | 54 for (uint32_t i = 0; i < num_bytes; i++) { |
| 55 if (b[i] != static_cast<unsigned char>(i + num_bytes)) | 55 if (b[i] != static_cast<unsigned char>(i + num_bytes)) |
| 56 return false; | 56 return false; |
| 57 } | 57 } |
| 58 return true; | 58 return true; |
| 59 } | 59 } |
| 60 | 60 |
| 61 void InitOnIOThread(RawChannel* raw_channel, RawChannel::Delegate* delegate) { | 61 void InitOnIOThread(RawChannel* raw_channel, RawChannel::Delegate* delegate) { |
| 62 CHECK(raw_channel->Init(delegate)); | 62 raw_channel->Init(delegate); |
| 63 } | 63 } |
| 64 | 64 |
| 65 bool WriteTestMessageToHandle(const embedder::PlatformHandle& handle, | 65 bool WriteTestMessageToHandle(const embedder::PlatformHandle& handle, |
| 66 uint32_t num_bytes) { | 66 uint32_t num_bytes) { |
| 67 scoped_ptr<MessageInTransit> message(MakeTestMessage(num_bytes)); | 67 scoped_ptr<MessageInTransit> message(MakeTestMessage(num_bytes)); |
| 68 | 68 |
| 69 size_t write_size = 0; | 69 size_t write_size = 0; |
| 70 mojo::test::BlockingWrite(handle, message->main_buffer(), | 70 mojo::test::BlockingWrite(handle, message->main_buffer(), |
| 71 message->main_buffer_size(), &write_size); | 71 message->main_buffer_size(), &write_size); |
| 72 return write_size == message->main_buffer_size(); | 72 return write_size == message->main_buffer_size(); |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 FROM_HERE, | 796 FROM_HERE, |
| 797 base::Bind(&RawChannel::Shutdown, base::Unretained(rc_read.get()))); | 797 base::Bind(&RawChannel::Shutdown, base::Unretained(rc_read.get()))); |
| 798 io_thread()->PostTaskAndWait( | 798 io_thread()->PostTaskAndWait( |
| 799 FROM_HERE, | 799 FROM_HERE, |
| 800 base::Bind(&RawChannel::Shutdown, base::Unretained(rc_write.get()))); | 800 base::Bind(&RawChannel::Shutdown, base::Unretained(rc_write.get()))); |
| 801 } | 801 } |
| 802 | 802 |
| 803 } // namespace | 803 } // namespace |
| 804 } // namespace system | 804 } // namespace system |
| 805 } // namespace mojo | 805 } // namespace mojo |
| OLD | NEW |