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

Unified Diff: mojo/edk/system/endpoint_relayer.h

Issue 782693004: Update mojo sdk to rev f6c8ec07c01deebc13178d516225fd12695c3dc2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: hack mojo_system_impl gypi for android :| 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
Index: mojo/edk/system/endpoint_relayer.h
diff --git a/mojo/edk/system/endpoint_relayer.h b/mojo/edk/system/endpoint_relayer.h
new file mode 100644
index 0000000000000000000000000000000000000000..4084452be6e7a093a5935a8177117bc1e8462134
--- /dev/null
+++ b/mojo/edk/system/endpoint_relayer.h
@@ -0,0 +1,49 @@
+// 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.
+
+#ifndef MOJO_EDK_SYSTEM_ENDPOINT_RELAYER_H_
+#define MOJO_EDK_SYSTEM_ENDPOINT_RELAYER_H_
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/synchronization/lock.h"
+#include "mojo/edk/system/channel_endpoint_client.h"
+#include "mojo/edk/system/system_impl_export.h"
+
+namespace mojo {
+namespace system {
+
+class ChannelEndpoint;
+
+// This is a simple |ChannelEndpointClient| that just relays messages between
+// two |ChannelEndpoint|s (without the overhead of |MessagePipe|).
+class MOJO_SYSTEM_IMPL_EXPORT EndpointRelayer : public ChannelEndpointClient {
+ public:
+ EndpointRelayer();
+
+ // Gets the other port number (i.e., 0 -> 1, 1 -> 0).
+ static unsigned GetPeerPort(unsigned port);
+
+ // Initialize this object. This must be called before any other method.
+ void Init(ChannelEndpoint* endpoint0, ChannelEndpoint* endpoint1);
+
+ // |ChannelEndpointClient| methods:
+ bool OnReadMessage(unsigned port, MessageInTransit* message) override;
+ void OnDetachFromChannel(unsigned port) override;
+
+ private:
+ virtual ~EndpointRelayer();
+
+ // TODO(vtl): We could probably get away without the lock if we had a
+ // thread-safe |scoped_refptr|.
+ base::Lock lock_; // Protects the following members.
+ scoped_refptr<ChannelEndpoint> endpoints_[2];
+
+ DISALLOW_COPY_AND_ASSIGN(EndpointRelayer);
+};
+
+} // namespace system
+} // namespace mojo
+
+#endif // MOJO_EDK_SYSTEM_ENDPOINT_RELAYER_H_

Powered by Google App Engine
This is Rietveld 408576698