| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> |
| 11 |
| 10 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 11 #include "ipc/ipc_export.h" | 13 #include "ipc/ipc_export.h" |
| 14 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" |
| 12 | 15 |
| 13 namespace IPC { | 16 namespace IPC { |
| 14 | 17 |
| 15 class Message; | 18 class Message; |
| 16 | 19 |
| 17 // Implemented by consumers of a Channel to receive messages. | 20 // Implemented by consumers of a Channel to receive messages. |
| 18 class IPC_EXPORT Listener { | 21 class IPC_EXPORT Listener { |
| 19 public: | 22 public: |
| 20 // Called when a message is received. Returns true iff the message was | 23 // Called when a message is received. Returns true iff the message was |
| 21 // handled. | 24 // handled. |
| 22 virtual bool OnMessageReceived(const Message& message) = 0; | 25 virtual bool OnMessageReceived(const Message& message) = 0; |
| 23 | 26 |
| 24 // Called when the channel is connected and we have received the internal | 27 // Called when the channel is connected and we have received the internal |
| 25 // Hello message from the peer. | 28 // Hello message from the peer. |
| 26 virtual void OnChannelConnected(int32_t peer_pid) {} | 29 virtual void OnChannelConnected(int32_t peer_pid) {} |
| 27 | 30 |
| 28 // Called when an error is detected that causes the channel to close. | 31 // Called when an error is detected that causes the channel to close. |
| 29 // This method is not called when a channel is closed normally. | 32 // This method is not called when a channel is closed normally. |
| 30 virtual void OnChannelError() {} | 33 virtual void OnChannelError() {} |
| 31 | 34 |
| 32 // Called when a message's deserialization failed. | 35 // Called when a message's deserialization failed. |
| 33 virtual void OnBadMessageReceived(const Message& message) {} | 36 virtual void OnBadMessageReceived(const Message& message) {} |
| 34 | 37 |
| 38 // Called when an associated interface request is received on a Channel and |
| 39 // the Channel has no registered handler for it. |
| 40 virtual void OnAssociatedInterfaceRequest( |
| 41 const std::string& interface_name, |
| 42 mojo::ScopedInterfaceEndpointHandle handle) {} |
| 43 |
| 35 #if defined(OS_POSIX) | 44 #if defined(OS_POSIX) |
| 36 // Called on the server side when a channel that listens for connections | 45 // Called on the server side when a channel that listens for connections |
| 37 // denies an attempt to connect. | 46 // denies an attempt to connect. |
| 38 virtual void OnChannelDenied() {} | 47 virtual void OnChannelDenied() {} |
| 39 | 48 |
| 40 // Called on the server side when a channel that listens for connections | 49 // Called on the server side when a channel that listens for connections |
| 41 // has an error that causes the listening channel to close. | 50 // has an error that causes the listening channel to close. |
| 42 virtual void OnChannelListenError() {} | 51 virtual void OnChannelListenError() {} |
| 43 #endif // OS_POSIX | 52 #endif // OS_POSIX |
| 44 | 53 |
| 45 protected: | 54 protected: |
| 46 virtual ~Listener() {} | 55 virtual ~Listener() {} |
| 47 }; | 56 }; |
| 48 | 57 |
| 49 } // namespace IPC | 58 } // namespace IPC |
| 50 | 59 |
| 51 #endif // IPC_IPC_LISTENER_H_ | 60 #endif // IPC_IPC_LISTENER_H_ |
| OLD | NEW |