1 // Copyright (c) 2012 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.
5 #ifndef IPC_IPC_LISTENER_H_
6 #define IPC_IPC_LISTENER_H_
10 #include "build/build_config.h"
11 #include "ipc/ipc_export.h"
17 // Implemented by consumers of a Channel to receive messages.
18 class IPC_EXPORT Listener
{
20 // Called when a message is received. Returns true iff the message was
22 virtual bool OnMessageReceived(const Message
& message
) = 0;
24 // Called when the channel is connected and we have received the internal
25 // Hello message from the peer.
26 virtual void OnChannelConnected(int32_t peer_pid
) {}
28 // Called when an error is detected that causes the channel to close.
29 // This method is not called when a channel is closed normally.
30 virtual void OnChannelError() {}
32 // Called when a message's deserialization failed.
33 virtual void OnBadMessageReceived(const Message
& message
) {}
36 // Called on the server side when a channel that listens for connections
37 // denies an attempt to connect.
38 virtual void OnChannelDenied() {}
40 // Called on the server side when a channel that listens for connections
41 // has an error that causes the listening channel to close.
42 virtual void OnChannelListenError() {}
46 virtual ~Listener() {}
51 #endif // IPC_IPC_LISTENER_H_