summaryrefslogtreecommitdiffstats
path: root/mojo/public/cpp/bindings/no_interface.h
blob: 4c3578926ab7a808062f5a44ea17700e5dbf6bfb (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
53
// 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_PUBLIC_CPP_BINDINGS_NO_INTERFACE_H_
#define MOJO_PUBLIC_CPP_BINDINGS_NO_INTERFACE_H_

#include "mojo/public/cpp/bindings/message.h"
#include "mojo/public/cpp/bindings/message_filter.h"
#include "mojo/public/cpp/system/core.h"

namespace mojo {

// NoInterface is for use in cases when a non-existent or empty interface is
// needed (e.g., when the Mojom "Peer" attribute is not present).

class NoInterfaceProxy;
class NoInterfaceStub;

class NoInterface {
 public:
  static const char* Name_;
  typedef NoInterfaceProxy Proxy_;
  typedef NoInterfaceStub Stub_;
  typedef PassThroughFilter RequestValidator_;
  typedef PassThroughFilter ResponseValidator_;
  typedef NoInterface Client;
  virtual ~NoInterface() {}
};

class NoInterfaceProxy : public NoInterface {
 public:
  explicit NoInterfaceProxy(MessageReceiver* receiver) {}
};

class NoInterfaceStub : public MessageReceiverWithResponder {
 public:
  NoInterfaceStub() {}
  void set_sink(NoInterface* sink) {}
  NoInterface* sink() { return nullptr; }
  bool Accept(Message* message) override;
  bool AcceptWithResponder(Message* message,
                           MessageReceiver* responder) override;
};

// AnyInterface is for use in cases where any interface would do (e.g., see the
// Shell::Connect method).

typedef NoInterface AnyInterface;

}  // namespace mojo

#endif  // MOJO_PUBLIC_CPP_BINDINGS_NO_INTERFACE_H_