Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/channel.h" | 5 #include "mojo/edk/system/channel.h" |
| 6 #include "base/memory/ptr_util.h" | 6 #include "base/memory/ptr_util.h" |
| 7 #include "testing/gmock/include/gmock/gmock.h" | 7 #include "testing/gmock/include/gmock/gmock.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace mojo { | 10 namespace mojo { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 // Notify that an error has occured and the Channel will cease operation. | 59 // Notify that an error has occured and the Channel will cease operation. |
| 60 void OnChannelError() override {} | 60 void OnChannelError() override {} |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 size_t payload_size_ = 0; | 63 size_t payload_size_ = 0; |
| 64 std::unique_ptr<char[]> payload_; | 64 std::unique_ptr<char[]> payload_; |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 Channel::MessagePtr CreateDefaultMessage(bool legacy_message) { | 67 Channel::MessagePtr CreateDefaultMessage(bool legacy_message) { |
| 68 const size_t payload_size = 100; | 68 const size_t payload_size = 100; |
| 69 Channel::Message::SetUseLegacyTransportProtocol(legacy_message); | |
|
Ken Rockot(use gerrit already)
2017/03/15 17:59:31
Hmm. This isn't really safe. Messages can be creat
Jay Civelli
2017/03/15 18:14:09
Sure, I was actually hesitant with that changed (I
| |
| 69 Channel::MessagePtr message = base::MakeUnique<Channel::Message>( | 70 Channel::MessagePtr message = base::MakeUnique<Channel::Message>( |
| 70 payload_size, 0, | 71 payload_size, 0); |
| 71 legacy_message ? Channel::Message::MessageType::NORMAL_LEGACY | |
| 72 : Channel::Message::MessageType::NORMAL); | |
| 73 char* payload = static_cast<char*>(message->mutable_payload()); | 72 char* payload = static_cast<char*>(message->mutable_payload()); |
| 74 for (size_t i = 0; i < payload_size; i++) { | 73 for (size_t i = 0; i < payload_size; i++) { |
| 75 payload[i] = static_cast<char>(i); | 74 payload[i] = static_cast<char>(i); |
| 76 } | 75 } |
| 77 return message; | 76 return message; |
| 78 } | 77 } |
| 79 | 78 |
| 80 void TestMemoryEqual(const void* data1, | 79 void TestMemoryEqual(const void* data1, |
| 81 size_t data1_size, | 80 size_t data1_size, |
| 82 const void* data2, | 81 const void* data2, |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 &next_read_size_hint)); | 167 &next_read_size_hint)); |
| 169 | 168 |
| 170 TestMemoryEqual(message->payload(), message->payload_size(), | 169 TestMemoryEqual(message->payload(), message->payload_size(), |
| 171 channel_delegate.GetReceivedPayload(), | 170 channel_delegate.GetReceivedPayload(), |
| 172 channel_delegate.GetReceivedPayloadSize()); | 171 channel_delegate.GetReceivedPayloadSize()); |
| 173 } | 172 } |
| 174 | 173 |
| 175 } // namespace | 174 } // namespace |
| 176 } // namespace edk | 175 } // namespace edk |
| 177 } // namespace mojo | 176 } // namespace mojo |
| OLD | NEW |