| 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 "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
| 6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "mojo/public/cpp/bindings/lib/message_builder.h" | 9 #include "mojo/public/cpp/bindings/lib/message_builder.h" |
| 10 #include "mojo/public/cpp/bindings/lib/message_internal.h" | 10 #include "mojo/public/cpp/bindings/lib/message_internal.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 base::StringPiece(reinterpret_cast<const char*>(message.data()), | 32 base::StringPiece(reinterpret_cast<const char*>(message.data()), |
| 33 message.data_num_bytes()))); | 33 message.data_num_bytes()))); |
| 34 CHECK_EQ(static_cast<int>(hex_message.size()), | 34 CHECK_EQ(static_cast<int>(hex_message.size()), |
| 35 base::WriteFile(path, hex_message.data(), | 35 base::WriteFile(path, hex_message.data(), |
| 36 static_cast<int>(hex_message.size()))); | 36 static_cast<int>(hex_message.size()))); |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Generates a message of type MessageData. The message uses the name 21, | 39 // Generates a message of type MessageData. The message uses the name 21, |
| 40 // with 4 bytes of payload: 0x9, 0x8, 0x7, 0x6. | 40 // with 4 bytes of payload: 0x9, 0x8, 0x7, 0x6. |
| 41 void GenerateMessageDataMessage() { | 41 void GenerateMessageDataMessage() { |
| 42 internal::MessageBuilder builder(static_cast<uint32_t>(21), | 42 MessageBuilder builder(static_cast<uint32_t>(21), static_cast<size_t>(4)); |
| 43 static_cast<size_t>(4)); | |
| 44 char* data = static_cast<char*>(builder.buffer()->Allocate(4)); | 43 char* data = static_cast<char*>(builder.buffer()->Allocate(4)); |
| 45 DCHECK(data); | 44 DCHECK(data); |
| 46 data[0] = 9; | 45 data[0] = 9; |
| 47 data[1] = 8; | 46 data[1] = 8; |
| 48 data[2] = 7; | 47 data[2] = 7; |
| 49 data[3] = 6; | 48 data[3] = 6; |
| 50 | 49 |
| 51 WriteMessageToFile(*builder.message(), | 50 WriteMessageToFile(*builder.message(), |
| 52 base::FilePath(FILE_PATH_LITERAL("message_data"))); | 51 base::FilePath(FILE_PATH_LITERAL("message_data"))); |
| 53 } | 52 } |
| 54 | 53 |
| 55 } // namespace | 54 } // namespace |
| 56 } // namespace mojo | 55 } // namespace mojo |
| 57 | 56 |
| 58 int main(int argc, char** argv) { | 57 int main(int argc, char** argv) { |
| 59 mojo::GenerateMessageDataMessage(); | 58 mojo::GenerateMessageDataMessage(); |
| 60 return 0; | 59 return 0; |
| 61 } | 60 } |
| OLD | NEW |