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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MOJO_EDK_SYSTEM_ENDPOINT_RELAYER_H_
6 #define MOJO_EDK_SYSTEM_ENDPOINT_RELAYER_H_
7
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/synchronization/lock.h"
11 #include "mojo/edk/system/channel_endpoint_client.h"
12 #include "mojo/edk/system/system_impl_export.h"
13
14 namespace mojo {
15 namespace system {
16
17 class ChannelEndpoint;
18
19 // This is a simple |ChannelEndpointClient| that just relays messages between
20 // two |ChannelEndpoint|s (without the overhead of |MessagePipe|).
21 class MOJO_SYSTEM_IMPL_EXPORT EndpointRelayer : public ChannelEndpointClient {
22 public:
23 EndpointRelayer();
24
25 // Gets the other port number (i.e., 0 -> 1, 1 -> 0).
26 static unsigned GetPeerPort(unsigned port);
27
28 // Initialize this object. This must be called before any other method.
29 void Init(ChannelEndpoint* endpoint0, ChannelEndpoint* endpoint1);
30
31 // |ChannelEndpointClient| methods:
32 bool OnReadMessage(unsigned port, MessageInTransit* message) override;
33 void OnDetachFromChannel(unsigned port) override;
34
35 private:
36 virtual ~EndpointRelayer();
37
38 // TODO(vtl): We could probably get away without the lock if we had a
39 // thread-safe |scoped_refptr|.
40 base::Lock lock_; // Protects the following members.
41 scoped_refptr<ChannelEndpoint> endpoints_[2];
42
43 DISALLOW_COPY_AND_ASSIGN(EndpointRelayer);
44 };
45
46 } // namespace system
47 } // namespace mojo
48
49 #endif // MOJO_EDK_SYSTEM_ENDPOINT_RELAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698