• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 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_PORTS_PORT_H_
6 #define MOJO_EDK_SYSTEM_PORTS_PORT_H_
7 
8 #include <memory>
9 #include <queue>
10 #include <utility>
11 #include <vector>
12 
13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/synchronization/lock.h"
16 #include "mojo/edk/system/ports/message_queue.h"
17 #include "mojo/edk/system/ports/user_data.h"
18 
19 namespace mojo {
20 namespace edk {
21 namespace ports {
22 
23 class Port : public base::RefCountedThreadSafe<Port> {
24  public:
25   enum State {
26     kUninitialized,
27     kReceiving,
28     kBuffering,
29     kProxying,
30     kClosed
31   };
32 
33   base::Lock lock;
34   State state;
35   NodeName peer_node_name;
36   PortName peer_port_name;
37   uint64_t next_sequence_num_to_send;
38   uint64_t last_sequence_num_to_receive;
39   MessageQueue message_queue;
40   std::unique_ptr<std::pair<NodeName, ScopedMessage>> send_on_proxy_removal;
41   scoped_refptr<UserData> user_data;
42   bool remove_proxy_on_last_message;
43   bool peer_closed;
44 
45   Port(uint64_t next_sequence_num_to_send,
46        uint64_t next_sequence_num_to_receive);
47 
48  private:
49   friend class base::RefCountedThreadSafe<Port>;
50 
51   ~Port();
52 
53   DISALLOW_COPY_AND_ASSIGN(Port);
54 };
55 
56 }  // namespace ports
57 }  // namespace edk
58 }  // namespace mojo
59 
60 #endif  // MOJO_EDK_SYSTEM_PORTS_PORT_H_
61