OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/public/cpp/bindings/message.h" | 5 #include "mojo/public/cpp/bindings/message.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/strings/stringprintf.h" |
15 | 16 |
16 namespace mojo { | 17 namespace mojo { |
17 | 18 |
18 Message::Message() { | 19 Message::Message() { |
19 } | 20 } |
20 | 21 |
21 Message::~Message() { | 22 Message::~Message() { |
22 CloseHandles(); | 23 CloseHandles(); |
23 } | 24 } |
24 | 25 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 void* new_buffer = nullptr; | 72 void* new_buffer = nullptr; |
72 rv = GetMessageBuffer(new_message.get(), &new_buffer); | 73 rv = GetMessageBuffer(new_message.get(), &new_buffer); |
73 CHECK_EQ(rv, MOJO_RESULT_OK); | 74 CHECK_EQ(rv, MOJO_RESULT_OK); |
74 | 75 |
75 memcpy(new_buffer, data(), data_num_bytes()); | 76 memcpy(new_buffer, data(), data_num_bytes()); |
76 buffer_.reset(); | 77 buffer_.reset(); |
77 | 78 |
78 return new_message; | 79 return new_message; |
79 } | 80 } |
80 | 81 |
| 82 void Message::NotifyBadMessage(const std::string& error) { |
| 83 buffer_->NotifyBadMessage(error); |
| 84 } |
| 85 |
81 void Message::CloseHandles() { | 86 void Message::CloseHandles() { |
82 for (std::vector<Handle>::iterator it = handles_.begin(); | 87 for (std::vector<Handle>::iterator it = handles_.begin(); |
83 it != handles_.end(); ++it) { | 88 it != handles_.end(); ++it) { |
84 if (it->is_valid()) | 89 if (it->is_valid()) |
85 CloseRaw(*it); | 90 CloseRaw(*it); |
86 } | 91 } |
87 } | 92 } |
88 | 93 |
89 MojoResult ReadMessage(MessagePipeHandle handle, Message* message) { | 94 MojoResult ReadMessage(MessagePipeHandle handle, Message* message) { |
90 MojoResult rv; | 95 MojoResult rv; |
(...skipping 20 matching lines...) Expand all Loading... |
111 | 116 |
112 if (rv != MOJO_RESULT_OK) | 117 if (rv != MOJO_RESULT_OK) |
113 return rv; | 118 return rv; |
114 | 119 |
115 message->InitializeFromMojoMessage( | 120 message->InitializeFromMojoMessage( |
116 std::move(mojo_message), num_bytes, &handles); | 121 std::move(mojo_message), num_bytes, &handles); |
117 return MOJO_RESULT_OK; | 122 return MOJO_RESULT_OK; |
118 } | 123 } |
119 | 124 |
120 } // namespace mojo | 125 } // namespace mojo |
OLD | NEW |