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

Side by Side Diff: components/nacl/loader/nacl_ipc_adapter.cc

Issue 150713003: Create IPC channel to communicate with the renderer in NaClListener::OnStart(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | « components/nacl/common/nacl_messages.h ('k') | components/nacl/loader/nacl_listener.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 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 "components/nacl/loader/nacl_ipc_adapter.h" 5 #include "components/nacl/loader/nacl_ipc_adapter.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 case ppapi::proxy::SerializedHandle::SOCKET: { 498 case ppapi::proxy::SerializedHandle::SOCKET: {
499 nacl_desc.reset(new NaClDescWrapper(NaClDescSyncSocketMake( 499 nacl_desc.reset(new NaClDescWrapper(NaClDescSyncSocketMake(
500 #if defined(OS_WIN) 500 #if defined(OS_WIN)
501 iter->descriptor() 501 iter->descriptor()
502 #else 502 #else
503 iter->descriptor().fd 503 iter->descriptor().fd
504 #endif 504 #endif
505 ))); 505 )));
506 break; 506 break;
507 } 507 }
508 case ppapi::proxy::SerializedHandle::CHANNEL_HANDLE: {
509 // Check that this came from a PpapiMsg_CreateNaClChannel message.
510 // This code here is only appropriate for that message.
511 DCHECK(msg.type() == PpapiMsg_CreateNaClChannel::ID);
512 IPC::ChannelHandle channel_handle =
513 IPC::Channel::GenerateVerifiedChannelID("nacl");
514 scoped_refptr<NaClIPCAdapter> ipc_adapter(
515 new NaClIPCAdapter(channel_handle, task_runner_.get()));
516 ipc_adapter->ConnectChannel();
517 #if defined(OS_POSIX)
518 channel_handle.socket = base::FileDescriptor(
519 ipc_adapter->TakeClientFileDescriptor(), true);
520 #endif
521 nacl_desc.reset(new NaClDescWrapper(ipc_adapter->MakeNaClDesc()));
522 // Send back a message that the channel was created.
523 scoped_ptr<IPC::Message> response(
524 new PpapiHostMsg_NaClChannelCreated(channel_handle));
525 task_runner_->PostTask(FROM_HERE,
526 base::Bind(&NaClIPCAdapter::SendMessageOnIOThread, this,
527 base::Passed(&response)));
528 break;
529 }
530 case ppapi::proxy::SerializedHandle::FILE: { 508 case ppapi::proxy::SerializedHandle::FILE: {
531 // Create the NaClDesc for the file descriptor. If quota checking is 509 // Create the NaClDesc for the file descriptor. If quota checking is
532 // required, wrap it in a NaClDescQuota. 510 // required, wrap it in a NaClDescQuota.
533 NaClDesc* desc = NaClDescIoDescFromHandleAllocCtor( 511 NaClDesc* desc = NaClDescIoDescFromHandleAllocCtor(
534 #if defined(OS_WIN) 512 #if defined(OS_WIN)
535 iter->descriptor(), 513 iter->descriptor(),
536 #else 514 #else
537 iter->descriptor().fd, 515 iter->descriptor().fd,
538 #endif 516 #endif
539 TranslatePepperFileReadWriteOpenFlags(iter->open_flags())); 517 TranslatePepperFileReadWriteOpenFlags(iter->open_flags()));
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 header.flags = msg.flags(); 665 header.flags = msg.flags();
688 header.num_fds = static_cast<int>(rewritten_msg->desc_count()); 666 header.num_fds = static_cast<int>(rewritten_msg->desc_count());
689 667
690 rewritten_msg->SetData(header, msg.payload(), msg.payload_size()); 668 rewritten_msg->SetData(header, msg.payload(), msg.payload_size());
691 locked_data_.to_be_received_.push(rewritten_msg); 669 locked_data_.to_be_received_.push(rewritten_msg);
692 } 670 }
693 671
694 int TranslatePepperFileReadWriteOpenFlagsForTesting(int32_t pp_open_flags) { 672 int TranslatePepperFileReadWriteOpenFlagsForTesting(int32_t pp_open_flags) {
695 return TranslatePepperFileReadWriteOpenFlags(pp_open_flags); 673 return TranslatePepperFileReadWriteOpenFlags(pp_open_flags);
696 } 674 }
OLDNEW
« no previous file with comments | « components/nacl/common/nacl_messages.h ('k') | components/nacl/loader/nacl_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698