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

Side by Side Diff: mojo/system/raw_channel.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/raw_channel.h ('k') | mojo/system/raw_channel_posix.cc » ('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 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/system/raw_channel.h" 5 #include "mojo/system/raw_channel.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // TODO(vtl): Validate that |message_size| is sane. 304 // TODO(vtl): Validate that |message_size| is sane.
305 while (remaining_bytes > 0 && 305 while (remaining_bytes > 0 &&
306 MessageInTransit::GetNextMessageSize( 306 MessageInTransit::GetNextMessageSize(
307 &read_buffer_->buffer_[read_buffer_start], remaining_bytes, 307 &read_buffer_->buffer_[read_buffer_start], remaining_bytes,
308 &message_size) && 308 &message_size) &&
309 remaining_bytes >= message_size) { 309 remaining_bytes >= message_size) {
310 MessageInTransit::View 310 MessageInTransit::View
311 message_view(message_size, &read_buffer_->buffer_[read_buffer_start]); 311 message_view(message_size, &read_buffer_->buffer_[read_buffer_start]);
312 DCHECK_EQ(message_view.total_size(), message_size); 312 DCHECK_EQ(message_view.total_size(), message_size);
313 313
314 const char* error_message = NULL;
315 if (!message_view.IsValid(GetSerializedPlatformHandleSize(),
316 &error_message)) {
317 DCHECK(error_message);
318 LOG(WARNING) << "Received invalid message: " << error_message;
319 read_stopped_ = true;
320 CallOnFatalError(Delegate::FATAL_ERROR_FAILED_READ);
321 return;
322 }
323
324 scoped_ptr<embedder::PlatformHandleVector> platform_handles;
325 if (message_view.transport_data_buffer()) {
326 size_t num_platform_handles;
327 const void* platform_handle_table;
328 TransportData::GetPlatformHandleTable(
329 message_view.transport_data_buffer(),
330 &num_platform_handles,
331 &platform_handle_table);
332
333 if (num_platform_handles > 0) {
334 platform_handles =
335 GetReadPlatformHandles(num_platform_handles,
336 platform_handle_table).Pass();
337 if (!platform_handles) {
338 LOG(WARNING) << "Invalid number of platform handles received";
339 read_stopped_ = true;
340 CallOnFatalError(Delegate::FATAL_ERROR_FAILED_READ);
341 return;
342 }
343 }
344 }
345
346 // TODO(vtl): In the case that we aren't expecting any platform handles,
347 // for the POSIX implementation, we should confirm that none are stored.
348
314 // Dispatch the message. 349 // Dispatch the message.
315 DCHECK(delegate_); 350 DCHECK(delegate_);
316 delegate_->OnReadMessage(message_view); 351 delegate_->OnReadMessage(message_view);
317 if (read_stopped_) { 352 if (read_stopped_) {
318 // |Shutdown()| was called in |OnReadMessage()|. 353 // |Shutdown()| was called in |OnReadMessage()|.
319 // TODO(vtl): Add test for this case. 354 // TODO(vtl): Add test for this case.
320 return; 355 return;
321 } 356 }
322 did_dispatch_message = true; 357 did_dispatch_message = true;
323 358
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 464
430 write_stopped_ = true; 465 write_stopped_ = true;
431 STLDeleteElements(&write_buffer_->message_queue_); 466 STLDeleteElements(&write_buffer_->message_queue_);
432 write_buffer_->platform_handles_offset_ = 0; 467 write_buffer_->platform_handles_offset_ = 0;
433 write_buffer_->data_offset_ = 0; 468 write_buffer_->data_offset_ = 0;
434 return false; 469 return false;
435 } 470 }
436 471
437 } // namespace system 472 } // namespace system
438 } // namespace mojo 473 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/raw_channel.h ('k') | mojo/system/raw_channel_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698