flutter_flutter/mojo/edk/system/proxy_message_pipe_endpoint.cc
James Robinson 5bb2480bcd Update to Mojo 4e4d51ce28a8edcb32b9c7f555e38e2ae84a825e, update deps
This updates to mojo 4e4d51ce28a and mojo sdk 711a0bcfb141b4 and updates the sky
package's pubspec.yaml dependency to '>=0.1.0 <0.2.0' to be compatible with
the current mojo package. This includes an update to the Mojo Dart generator to
produce real classes for enums and the corresponding updates for users of the
KeyboardType enum in Sky as well as one scoped_ptr->std::unique_ptr in shell
corresponding to a change in the Mojo EDK.

When a new version of the sky and sky_services package are pushed this will fix
domokit/mojo#440.
2015-09-23 17:26:46 -07:00

68 lines
1.8 KiB
C++

// 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 <utility>
#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_);
}
scoped_refptr<ChannelEndpoint>
ProxyMessagePipeEndpoint::ReleaseChannelEndpoint() {
DCHECK(channel_endpoint_);
scoped_refptr<ChannelEndpoint> rv;
rv.swap(channel_endpoint_);
return rv;
}
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(
std::unique_ptr<MessageInTransit> message) {
DCHECK(channel_endpoint_);
bool ok = channel_endpoint_->EnqueueMessage(std::move(message));
LOG_IF(WARNING, !ok) << "Failed to write enqueue message to channel";
}
void ProxyMessagePipeEndpoint::Close() {
DetachIfNecessary();
}
void ProxyMessagePipeEndpoint::DetachIfNecessary() {
if (channel_endpoint_) {
channel_endpoint_->DetachFromClient();
channel_endpoint_ = nullptr;
}
}
} // namespace system
} // namespace mojo