Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(645)

Unified Diff: mojo/edk/system/incoming_endpoint.cc

Issue 799113004: Update mojo sdk to rev 59145288bae55b0fce4276b017df6a1117bcf00f (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add mojo's ply to checklicenses whitelist Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/system/incoming_endpoint.h ('k') | mojo/edk/system/local_message_pipe_endpoint.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/incoming_endpoint.cc
diff --git a/mojo/edk/system/incoming_endpoint.cc b/mojo/edk/system/incoming_endpoint.cc
new file mode 100644
index 0000000000000000000000000000000000000000..14f1a71816287e0a4e41dacece0838aac099b036
--- /dev/null
+++ b/mojo/edk/system/incoming_endpoint.cc
@@ -0,0 +1,59 @@
+// Copyright 2014 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/incoming_endpoint.h"
+
+#include "base/logging.h"
+#include "mojo/edk/system/channel_endpoint.h"
+#include "mojo/edk/system/message_in_transit.h"
+#include "mojo/edk/system/message_pipe.h"
+
+namespace mojo {
+namespace system {
+
+IncomingEndpoint::IncomingEndpoint() {
+}
+
+scoped_refptr<ChannelEndpoint> IncomingEndpoint::Init() {
+ endpoint_ = new ChannelEndpoint(this, 0);
+ return endpoint_;
+}
+
+scoped_refptr<MessagePipe> IncomingEndpoint::ConvertToMessagePipe() {
+ base::AutoLock locker(lock_);
+ scoped_refptr<MessagePipe> message_pipe(
+ MessagePipe::CreateLocalProxyFromExisting(&message_queue_,
+ endpoint_.get()));
+ DCHECK(message_queue_.IsEmpty());
+ endpoint_ = nullptr;
+ return message_pipe;
+}
+
+void IncomingEndpoint::Close() {
+ base::AutoLock locker(lock_);
+ if (endpoint_) {
+ endpoint_->DetachFromClient();
+ endpoint_ = nullptr;
+ }
+}
+
+bool IncomingEndpoint::OnReadMessage(unsigned /*port*/,
+ MessageInTransit* message) {
+ base::AutoLock locker(lock_);
+ if (!endpoint_)
+ return false;
+
+ message_queue_.AddMessage(make_scoped_ptr(message));
+ return true;
+}
+
+void IncomingEndpoint::OnDetachFromChannel(unsigned /*port*/) {
+ Close();
+}
+
+IncomingEndpoint::~IncomingEndpoint() {
+}
+
+} // namespace system
+} // namespace mojo
« no previous file with comments | « mojo/edk/system/incoming_endpoint.h ('k') | mojo/edk/system/local_message_pipe_endpoint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698