diff options
author | James Robinson <jamesr@chromium.org> | 2014-10-02 17:19:39 -0700 |
---|---|---|
committer | James Robinson <jamesr@chromium.org> | 2014-10-03 00:20:26 +0000 |
commit | ee7ff197a98da4636f33bd713de784948b487bd4 (patch) | |
tree | bde85518c9be483f1e0a32c98a6dbb5e9b93e62e /mojo/edk/system/proxy_message_pipe_endpoint.cc | |
parent | 20894f54fc1460d9f13210b427a077267ebe86ee (diff) | |
download | chromium_src-ee7ff197a98da4636f33bd713de784948b487bd4.zip chromium_src-ee7ff197a98da4636f33bd713de784948b487bd4.tar.gz chromium_src-ee7ff197a98da4636f33bd713de784948b487bd4.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
Review URL: https://codereview.chromium.org/621153003
Cr-Commit-Position: refs/heads/master@{#297958}
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 |