Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: mojo/system/message_in_transit.cc

Issue 277083003: Mojo: (Theoretically) implement the read side of platform handle passing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: asdf Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mojo/system/message_in_transit.h ('k') | mojo/system/raw_channel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/system/message_in_transit.h" 5 #include "mojo/system/message_in_transit.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 MessageInTransit::View::View(size_t message_size, const void* buffer) 51 MessageInTransit::View::View(size_t message_size, const void* buffer)
52 : buffer_(buffer) { 52 : buffer_(buffer) {
53 size_t next_message_size = 0; 53 size_t next_message_size = 0;
54 DCHECK(MessageInTransit::GetNextMessageSize(buffer_, message_size, 54 DCHECK(MessageInTransit::GetNextMessageSize(buffer_, message_size,
55 &next_message_size)); 55 &next_message_size));
56 DCHECK_EQ(message_size, next_message_size); 56 DCHECK_EQ(message_size, next_message_size);
57 // This should be equivalent. 57 // This should be equivalent.
58 DCHECK_EQ(message_size, total_size()); 58 DCHECK_EQ(message_size, total_size());
59 } 59 }
60 60
61 bool MessageInTransit::View::IsValid(const char** error_message) const { 61 bool MessageInTransit::View::IsValid(size_t serialized_platform_handle_size,
62 const char** error_message) const {
62 // Note: This also implies a check on the |main_buffer_size()|, which is just 63 // Note: This also implies a check on the |main_buffer_size()|, which is just
63 // |RoundUpMessageAlignment(sizeof(Header) + num_bytes())|. 64 // |RoundUpMessageAlignment(sizeof(Header) + num_bytes())|.
64 if (num_bytes() > kMaxMessageNumBytes) { 65 if (num_bytes() > kMaxMessageNumBytes) {
65 *error_message = "Message data payload too large"; 66 *error_message = "Message data payload too large";
66 return false; 67 return false;
67 } 68 }
68 69
69 if (transport_data_buffer_size() > 0) { 70 if (transport_data_buffer_size() > 0) {
70 const char* e = TransportData::ValidateBuffer(transport_data_buffer(), 71 const char* e =
71 transport_data_buffer_size()); 72 TransportData::ValidateBuffer(serialized_platform_handle_size,
73 transport_data_buffer(),
74 transport_data_buffer_size());
72 if (e) { 75 if (e) {
73 *error_message = e; 76 *error_message = e;
74 return false; 77 return false;
75 } 78 }
76 } 79 }
77 80
78 return true; 81 return true;
79 } 82 }
80 83
81 MessageInTransit::MessageInTransit(Type type, 84 MessageInTransit::MessageInTransit(Type type,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 DCHECK_EQ(main_buffer_size_ % kMessageAlignment, 0u); 183 DCHECK_EQ(main_buffer_size_ % kMessageAlignment, 0u);
181 header()->total_size = static_cast<uint32_t>(main_buffer_size_); 184 header()->total_size = static_cast<uint32_t>(main_buffer_size_);
182 if (transport_data_) { 185 if (transport_data_) {
183 header()->total_size += 186 header()->total_size +=
184 static_cast<uint32_t>(transport_data_->buffer_size()); 187 static_cast<uint32_t>(transport_data_->buffer_size());
185 } 188 }
186 } 189 }
187 190
188 } // namespace system 191 } // namespace system
189 } // namespace mojo 192 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/message_in_transit.h ('k') | mojo/system/raw_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698