no_interface.h revision 46d4c2bc3267f3f028f39e7e311b0f89aba2e4fd
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_PUBLIC_CPP_BINDINGS_NO_INTERFACE_H_
6#define MOJO_PUBLIC_CPP_BINDINGS_NO_INTERFACE_H_
7
8#include <assert.h>
9
10#include "mojo/public/cpp/bindings/message.h"
11#include "mojo/public/cpp/bindings/message_filter.h"
12#include "mojo/public/cpp/system/core.h"
13
14namespace mojo {
15
16// NoInterface is for use in cases when a non-existent or empty interface is
17// needed (e.g., when the Mojom "Peer" attribute is not present).
18
19class NoInterfaceProxy;
20class NoInterfaceStub;
21
22class NoInterface {
23 public:
24  static const char* Name_;
25  typedef NoInterfaceProxy Proxy_;
26  typedef NoInterfaceStub Stub_;
27  typedef PassThroughFilter RequestValidator_;
28  typedef PassThroughFilter ResponseValidator_;
29  typedef NoInterface Client;
30  virtual ~NoInterface() {}
31};
32
33class NoInterfaceProxy : public NoInterface {
34 public:
35  explicit NoInterfaceProxy(MessageReceiver* receiver) {}
36};
37
38class NoInterfaceStub : public MessageReceiverWithResponder {
39 public:
40  NoInterfaceStub() {}
41  void set_sink(NoInterface* sink) {}
42  NoInterface* sink() { return NULL; }
43  virtual bool Accept(Message* message) MOJO_OVERRIDE;
44  virtual bool AcceptWithResponder(Message* message, MessageReceiver* responder)
45      MOJO_OVERRIDE;
46};
47
48
49// AnyInterface is for use in cases where any interface would do (e.g., see the
50// Shell::Connect method).
51
52typedef NoInterface AnyInterface;
53
54}  // namespace mojo
55
56#endif  // MOJO_PUBLIC_CPP_BINDINGS_NO_INTERFACE_H_
57