Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "ipc/ipc_channel_proxy.h" | |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 enum BufferSizeStatus { | 19 enum BufferSizeStatus { |
| 19 // The buffer contains a full message with no extra bytes. | 20 // The buffer contains a full message with no extra bytes. |
| 20 MESSAGE_IS_COMPLETE, | 21 MESSAGE_IS_COMPLETE, |
| 21 | 22 |
| 22 // The message doesn't fit and the buffer contains only some of it. | 23 // The message doesn't fit and the buffer contains only some of it. |
| 23 MESSAGE_IS_TRUNCATED, | 24 MESSAGE_IS_TRUNCATED, |
| 24 | 25 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 } | 112 } |
| 112 | 113 |
| 113 NaClIPCAdapter::NaClIPCAdapter(const IPC::ChannelHandle& handle, | 114 NaClIPCAdapter::NaClIPCAdapter(const IPC::ChannelHandle& handle, |
| 114 base::TaskRunner* runner) | 115 base::TaskRunner* runner) |
| 115 : lock_(), | 116 : lock_(), |
| 116 cond_var_(&lock_), | 117 cond_var_(&lock_), |
| 117 task_runner_(runner), | 118 task_runner_(runner), |
| 118 locked_data_() { | 119 locked_data_() { |
| 119 io_thread_data_.channel_.reset( | 120 io_thread_data_.channel_.reset( |
| 120 new IPC::Channel(handle, IPC::Channel::MODE_SERVER, this)); | 121 new IPC::Channel(handle, IPC::Channel::MODE_SERVER, this)); |
| 122 DCHECK(io_thread_data_.channel_->Connect()); | |
|
dmichael (off chromium)
2012/05/07 20:30:19
You don't want to do this inside DCHECK, since it
bbudge
2012/05/07 21:39:18
I think that's OK. I've seen it in other calls to
| |
| 121 } | 123 } |
| 122 | 124 |
| 123 NaClIPCAdapter::NaClIPCAdapter(scoped_ptr<IPC::Channel> channel, | 125 NaClIPCAdapter::NaClIPCAdapter(scoped_ptr<IPC::Channel> channel, |
| 124 base::TaskRunner* runner) | 126 base::TaskRunner* runner) |
| 125 : lock_(), | 127 : lock_(), |
| 126 cond_var_(&lock_), | 128 cond_var_(&lock_), |
| 127 task_runner_(runner), | 129 task_runner_(runner), |
| 128 locked_data_() { | 130 locked_data_() { |
| 129 io_thread_data_.channel_ = channel.Pass(); | 131 io_thread_data_.channel_ = channel.Pass(); |
| 130 } | 132 } |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 locked_data_.to_be_sent_.swap(empty); | 329 locked_data_.to_be_sent_.swap(empty); |
| 328 } | 330 } |
| 329 | 331 |
| 330 void NaClIPCAdapter::CloseChannelOnIOThread() { | 332 void NaClIPCAdapter::CloseChannelOnIOThread() { |
| 331 io_thread_data_.channel_->Close(); | 333 io_thread_data_.channel_->Close(); |
| 332 } | 334 } |
| 333 | 335 |
| 334 void NaClIPCAdapter::SendMessageOnIOThread(scoped_ptr<IPC::Message> message) { | 336 void NaClIPCAdapter::SendMessageOnIOThread(scoped_ptr<IPC::Message> message) { |
| 335 io_thread_data_.channel_->Send(message.release()); | 337 io_thread_data_.channel_->Send(message.release()); |
| 336 } | 338 } |
| OLD | NEW |