diff options
author | jamesr <jamesr@chromium.org> | 2014-10-02 21:26:48 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-03 04:27:07 +0000 |
commit | a03ae49d253d7d1f517e2f92146a6ba201c78aa6 (patch) | |
tree | df4eae1239d49490fa4e85d184b9000224a7a31c /mojo/edk/system/proxy_message_pipe_endpoint.cc | |
parent | 24b9789375c3c23d0d10e5197c6a7674946ea44b (diff) | |
download | chromium_src-a03ae49d253d7d1f517e2f92146a6ba201c78aa6.zip chromium_src-a03ae49d253d7d1f517e2f92146a6ba201c78aa6.tar.gz chromium_src-a03ae49d253d7d1f517e2f92146a6ba201c78aa6.tar.bz2 |
Move mojo edk into mojo/edk
This creates a mojo/edk directory which contains the "embedder developer
kit" aka the set of code needed to embed mojo code.
mojo/edk/embedder = code from mojo/embedder
mojo/edk/system = code from mojo/system
mojo/edk/test = code used to test the previous two, from mojo/common/test
mojo/edk/ can only depend on mojo/public/, base/ and itself.
R=viettrungluu@chromium.org
TBR=sky@chromium.org for file renames
Committed: https://chromium.googlesource.com/chromium/src/+/ee7ff197a98da4636f33bd713de784948b487bd4
Review URL: https://codereview.chromium.org/621153003
Cr-Commit-Position: refs/heads/master@{#297986}
Diffstat (limited to 'mojo/edk/system/proxy_message_pipe_endpoint.cc')
-rw-r--r-- | mojo/edk/system/proxy_message_pipe_endpoint.cc | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/mojo/edk/system/proxy_message_pipe_endpoint.cc b/mojo/edk/system/proxy_message_pipe_endpoint.cc new file mode 100644 index 0000000..85437bb --- /dev/null +++ b/mojo/edk/system/proxy_message_pipe_endpoint.cc @@ -0,0 +1,57 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "mojo/edk/system/proxy_message_pipe_endpoint.h" + +#include <string.h> + +#include "base/logging.h" +#include "mojo/edk/system/channel_endpoint.h" +#include "mojo/edk/system/local_message_pipe_endpoint.h" +#include "mojo/edk/system/message_pipe_dispatcher.h" + +namespace mojo { +namespace system { + +ProxyMessagePipeEndpoint::ProxyMessagePipeEndpoint( + ChannelEndpoint* channel_endpoint) + : channel_endpoint_(channel_endpoint) { +} + +ProxyMessagePipeEndpoint::~ProxyMessagePipeEndpoint() { + DCHECK(!channel_endpoint_.get()); +} + +MessagePipeEndpoint::Type ProxyMessagePipeEndpoint::GetType() const { + return kTypeProxy; +} + +bool ProxyMessagePipeEndpoint::OnPeerClose() { + DetachIfNecessary(); + return false; +} + +// Note: We may have to enqueue messages even when our (local) peer isn't open +// -- it may have been written to and closed immediately, before we were ready. +// This case is handled in |Run()| (which will call us). +void ProxyMessagePipeEndpoint::EnqueueMessage( + scoped_ptr<MessageInTransit> message) { + DCHECK(channel_endpoint_.get()); + LOG_IF(WARNING, !channel_endpoint_->EnqueueMessage(message.Pass())) + << "Failed to write enqueue message to channel"; +} + +void ProxyMessagePipeEndpoint::Close() { + DetachIfNecessary(); +} + +void ProxyMessagePipeEndpoint::DetachIfNecessary() { + if (channel_endpoint_.get()) { + channel_endpoint_->DetachFromMessagePipe(); + channel_endpoint_ = nullptr; + } +} + +} // namespace system +} // namespace mojo |