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

Side by Side Diff: chrome/nacl/nacl_ipc_adapter.cc

Issue 10625007: Revert 143656 - Add an IPC channel between the NaCl loader process and the renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 | « chrome/nacl/nacl_ipc_adapter.h ('k') | chrome/nacl/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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/nacl/nacl_ipc_adapter.h" 5 #include "chrome/nacl/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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 return -1; 67 return -1;
68 return static_cast<ssize_t>( 68 return static_cast<ssize_t>(
69 ToAdapter(handle)->Send(static_cast<char*>(msg->iov[0].base), 69 ToAdapter(handle)->Send(static_cast<char*>(msg->iov[0].base),
70 msg->iov[0].length)); 70 msg->iov[0].length));
71 } 71 }
72 72
73 ssize_t NaClDescCustomRecvMsg(void* handle, NaClImcTypedMsgHdr* msg, 73 ssize_t NaClDescCustomRecvMsg(void* handle, NaClImcTypedMsgHdr* msg,
74 int /* flags */) { 74 int /* flags */) {
75 if (msg->iov_length != 1) 75 if (msg->iov_length != 1)
76 return -1; 76 return -1;
77 msg->ndesc_length = 0; // Messages with descriptors aren't supported yet.
78 return static_cast<ssize_t>( 77 return static_cast<ssize_t>(
79 ToAdapter(handle)->BlockingReceive(static_cast<char*>(msg->iov[0].base), 78 ToAdapter(handle)->BlockingReceive(static_cast<char*>(msg->iov[0].base),
80 msg->iov[0].length)); 79 msg->iov[0].length));
81 } 80 }
82 81
83 NaClDesc* MakeNaClDescCustom(NaClIPCAdapter* adapter) { 82 NaClDesc* MakeNaClDescCustom(NaClIPCAdapter* adapter) {
84 NaClDescCustomFuncs funcs = NACL_DESC_CUSTOM_FUNCS_INITIALIZER; 83 NaClDescCustomFuncs funcs = NACL_DESC_CUSTOM_FUNCS_INITIALIZER;
85 funcs.Destroy = NaClDescCustomDestroy; 84 funcs.Destroy = NaClDescCustomDestroy;
86 funcs.SendMsg = NaClDescCustomSendMsg; 85 funcs.SendMsg = NaClDescCustomSendMsg;
87 funcs.RecvMsg = NaClDescCustomRecvMsg; 86 funcs.RecvMsg = NaClDescCustomRecvMsg;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 cond_var_.Signal(); 274 cond_var_.Signal();
276 275
277 task_runner_->PostTask(FROM_HERE, 276 task_runner_->PostTask(FROM_HERE,
278 base::Bind(&NaClIPCAdapter::CloseChannelOnIOThread, this)); 277 base::Bind(&NaClIPCAdapter::CloseChannelOnIOThread, this));
279 } 278 }
280 279
281 NaClDesc* NaClIPCAdapter::MakeNaClDesc() { 280 NaClDesc* NaClIPCAdapter::MakeNaClDesc() {
282 return MakeNaClDescCustom(this); 281 return MakeNaClDescCustom(this);
283 } 282 }
284 283
285 #if defined(OS_POSIX)
286 int NaClIPCAdapter::TakeClientFileDescriptor() {
287 return io_thread_data_.channel_->TakeClientFileDescriptor();
288 }
289 #endif
290
291 bool NaClIPCAdapter::OnMessageReceived(const IPC::Message& message) { 284 bool NaClIPCAdapter::OnMessageReceived(const IPC::Message& message) {
292 { 285 {
293 base::AutoLock lock(lock_); 286 base::AutoLock lock(lock_);
294 287
295 // There is some padding in this structure (the "padding" member is 16 288 // There is some padding in this structure (the "padding" member is 16
296 // bits but this then gets padded to 32 bits). We want to be sure not to 289 // bits but this then gets padded to 32 bits). We want to be sure not to
297 // leak data to the untrusted plugin, so zero everything out first. 290 // leak data to the untrusted plugin, so zero everything out first.
298 NaClMessageHeader header; 291 NaClMessageHeader header;
299 memset(&header, 0, sizeof(NaClMessageHeader)); 292 memset(&header, 0, sizeof(NaClMessageHeader));
300 293
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 NOTREACHED(); 393 NOTREACHED();
401 } 394 }
402 395
403 void NaClIPCAdapter::CloseChannelOnIOThread() { 396 void NaClIPCAdapter::CloseChannelOnIOThread() {
404 io_thread_data_.channel_->Close(); 397 io_thread_data_.channel_->Close();
405 } 398 }
406 399
407 void NaClIPCAdapter::SendMessageOnIOThread(scoped_ptr<IPC::Message> message) { 400 void NaClIPCAdapter::SendMessageOnIOThread(scoped_ptr<IPC::Message> message) {
408 io_thread_data_.channel_->Send(message.release()); 401 io_thread_data_.channel_->Send(message.release());
409 } 402 }
OLDNEW
« no previous file with comments | « chrome/nacl/nacl_ipc_adapter.h ('k') | chrome/nacl/nacl_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698