| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef IPC_IPC_LISTENER_H_ | 5 #ifndef IPC_IPC_LISTENER_H_ |
| 6 #define IPC_IPC_LISTENER_H_ | 6 #define IPC_IPC_LISTENER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include <stdint.h> |
| 9 |
| 9 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 10 #include "ipc/ipc_export.h" | 11 #include "ipc/ipc_export.h" |
| 11 | 12 |
| 12 namespace IPC { | 13 namespace IPC { |
| 13 | 14 |
| 14 class Message; | 15 class Message; |
| 15 | 16 |
| 16 // Implemented by consumers of a Channel to receive messages. | 17 // Implemented by consumers of a Channel to receive messages. |
| 17 class IPC_EXPORT Listener { | 18 class IPC_EXPORT Listener { |
| 18 public: | 19 public: |
| 19 // Called when a message is received. Returns true iff the message was | 20 // Called when a message is received. Returns true iff the message was |
| 20 // handled. | 21 // handled. |
| 21 virtual bool OnMessageReceived(const Message& message) = 0; | 22 virtual bool OnMessageReceived(const Message& message) = 0; |
| 22 | 23 |
| 23 // Called when the channel is connected and we have received the internal | 24 // Called when the channel is connected and we have received the internal |
| 24 // Hello message from the peer. | 25 // Hello message from the peer. |
| 25 virtual void OnChannelConnected(int32 peer_pid) {} | 26 virtual void OnChannelConnected(int32_t peer_pid) {} |
| 26 | 27 |
| 27 // Called when an error is detected that causes the channel to close. | 28 // Called when an error is detected that causes the channel to close. |
| 28 // This method is not called when a channel is closed normally. | 29 // This method is not called when a channel is closed normally. |
| 29 virtual void OnChannelError() {} | 30 virtual void OnChannelError() {} |
| 30 | 31 |
| 31 // Called when a message's deserialization failed. | 32 // Called when a message's deserialization failed. |
| 32 virtual void OnBadMessageReceived(const Message& message) {} | 33 virtual void OnBadMessageReceived(const Message& message) {} |
| 33 | 34 |
| 34 #if defined(OS_POSIX) | 35 #if defined(OS_POSIX) |
| 35 // Called on the server side when a channel that listens for connections | 36 // Called on the server side when a channel that listens for connections |
| 36 // denies an attempt to connect. | 37 // denies an attempt to connect. |
| 37 virtual void OnChannelDenied() {} | 38 virtual void OnChannelDenied() {} |
| 38 | 39 |
| 39 // Called on the server side when a channel that listens for connections | 40 // Called on the server side when a channel that listens for connections |
| 40 // has an error that causes the listening channel to close. | 41 // has an error that causes the listening channel to close. |
| 41 virtual void OnChannelListenError() {} | 42 virtual void OnChannelListenError() {} |
| 42 #endif // OS_POSIX | 43 #endif // OS_POSIX |
| 43 | 44 |
| 44 protected: | 45 protected: |
| 45 virtual ~Listener() {} | 46 virtual ~Listener() {} |
| 46 }; | 47 }; |
| 47 | 48 |
| 48 } // namespace IPC | 49 } // namespace IPC |
| 49 | 50 |
| 50 #endif // IPC_IPC_LISTENER_H_ | 51 #endif // IPC_IPC_LISTENER_H_ |
| OLD | NEW |