summaryrefslogtreecommitdiffstats
path: root/ipc/ipc_endpoint.h
blob: 2ace1fe999c946ace33079e70747adb2d736623e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2015 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 IPC_IPC_ENDPOINT_H_
#define IPC_IPC_ENDPOINT_H_

#include "base/process/process_handle.h"
#include "ipc/ipc_export.h"
#include "ipc/ipc_sender.h"

namespace IPC {

// An Endpoint is an abstract base class whose interface provides sending
// functionality, and some receiving functionality. It mostly exists to provide
// a common interface to Channel and ProxyChannel.
class IPC_EXPORT Endpoint : public Sender {
 public:
  Endpoint();
  ~Endpoint() override {}

  // Get the process ID for the connected peer.
  //
  // Returns base::kNullProcessId if the peer is not connected yet. Watch out
  // for race conditions. You can easily get a channel to another process, but
  // if your process has not yet processed the "hello" message from the remote
  // side, this will fail. You should either make sure calling this is either
  // in response to a message from the remote side (which guarantees that it's
  // been connected), or you wait for the "connected" notification on the
  // listener.
  virtual base::ProcessId GetPeerPID() const = 0;

  // A callback that indicates that is_attachment_broker_endpoint() has been
  // changed.
  virtual void OnSetAttachmentBrokerEndpoint(){};

  // Whether this channel is used as an endpoint for sending and receiving
  // brokerable attachment messages to/from the broker process.
  void SetAttachmentBrokerEndpoint(bool is_endpoint);

 protected:
  bool is_attachment_broker_endpoint() { return attachment_broker_endpoint_; }

 private:
  // Whether this channel is used as an endpoint for sending and receiving
  // brokerable attachment messages to/from the broker process.
  bool attachment_broker_endpoint_;
};

}  // namespace IPC

#endif  // IPC_IPC_ENDPOINT_H_