Index: sandbox/linux/syscall_broker/broker_host.cc |
diff --git a/sandbox/linux/syscall_broker/broker_host.cc b/sandbox/linux/syscall_broker/broker_host.cc |
index 995641d6dcc2c4b6335f98bfb540d242016bdcbf..29300f7e374359ec4038db80c46105de658aa60f 100644 |
--- a/sandbox/linux/syscall_broker/broker_host.cc |
+++ b/sandbox/linux/syscall_broker/broker_host.cc |
@@ -154,8 +154,9 @@ bool HandleRemoteCommand(const BrokerPolicy& policy, |
} // namespace |
-BrokerHost::BrokerHost(const BrokerPolicy& broker_policy, int ipc_channel) |
- : broker_policy_(broker_policy), ipc_channel_(ipc_channel) { |
+BrokerHost::BrokerHost(const BrokerPolicy& broker_policy, |
+ BrokerChannel::EndPoint ipc_channel) |
+ : broker_policy_(broker_policy), ipc_channel_(ipc_channel.Pass()) { |
} |
BrokerHost::~BrokerHost() { |
@@ -165,17 +166,16 @@ BrokerHost::~BrokerHost() { |
// A request should have a file descriptor attached on which we will reply and |
// that we will then close. |
// A request should start with an int that will be used as the command type. |
-bool BrokerHost::HandleRequest() const { |
+BrokerHost::RequestStatus BrokerHost::HandleRequest() const { |
ScopedVector<base::ScopedFD> fds; |
char buf[kMaxMessageLength]; |
errno = 0; |
const ssize_t msg_len = |
- UnixDomainSocket::RecvMsg(ipc_channel_, buf, sizeof(buf), &fds); |
+ UnixDomainSocket::RecvMsg(ipc_channel_.get(), buf, sizeof(buf), &fds); |
if (msg_len == 0 || (msg_len == -1 && errno == ECONNRESET)) { |
// EOF from the client, or the client died, we should die. |
- // TODO(jln): change this. |
- _exit(0); |
+ return RequestStatus::LOST_CLIENT; |
} |
// The client should send exactly one file descriptor, on which we |
@@ -183,7 +183,7 @@ bool BrokerHost::HandleRequest() const { |
// TODO(mdempsky): ScopedVector doesn't have 'at()', only 'operator[]'. |
if (msg_len < 0 || fds.size() != 1 || fds[0]->get() < 0) { |
PLOG(ERROR) << "Error reading message from the client"; |
- return false; |
+ return RequestStatus::FAILURE; |
} |
base::ScopedFD temporary_ipc(fds[0]->Pass()); |
@@ -192,28 +192,32 @@ bool BrokerHost::HandleRequest() const { |
PickleIterator iter(pickle); |
int command_type; |
if (pickle.ReadInt(&iter, &command_type)) { |
- bool r = false; |
+ bool command_handled = false; |
// Go through all the possible IPC messages. |
switch (command_type) { |
case COMMAND_ACCESS: |
case COMMAND_OPEN: |
// We reply on the file descriptor sent to us via the IPC channel. |
- r = HandleRemoteCommand(broker_policy_, |
- static_cast<IPCCommand>(command_type), |
- temporary_ipc.get(), |
- pickle, |
- iter); |
+ command_handled = HandleRemoteCommand( |
+ broker_policy_, static_cast<IPCCommand>(command_type), |
+ temporary_ipc.get(), pickle, iter); |
break; |
default: |
NOTREACHED(); |
- r = false; |
break; |
} |
- return r; |
+ |
+ if (command_handled) { |
+ return RequestStatus::SUCCESS; |
+ } else { |
+ return RequestStatus::FAILURE; |
+ } |
+ |
+ NOTREACHED(); |
} |
LOG(ERROR) << "Error parsing IPC request"; |
- return false; |
+ return RequestStatus::FAILURE; |
} |
} // namespace syscall_broker |