| 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_CHANNEL_PROXY_H_ | 5 #ifndef IPC_IPC_CHANNEL_PROXY_H_ |
| 6 #define IPC_IPC_CHANNEL_PROXY_H_ | 6 #define IPC_IPC_CHANNEL_PROXY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 public: | 51 public: |
| 52 | 52 |
| 53 struct MessageFilterTraits; | 53 struct MessageFilterTraits; |
| 54 | 54 |
| 55 // A class that receives messages on the thread where the IPC channel is | 55 // A class that receives messages on the thread where the IPC channel is |
| 56 // running. It can choose to prevent the default action for an IPC message. | 56 // running. It can choose to prevent the default action for an IPC message. |
| 57 class IPC_EXPORT MessageFilter | 57 class IPC_EXPORT MessageFilter |
| 58 : public base::RefCountedThreadSafe<MessageFilter, MessageFilterTraits> { | 58 : public base::RefCountedThreadSafe<MessageFilter, MessageFilterTraits> { |
| 59 public: | 59 public: |
| 60 MessageFilter(); | 60 MessageFilter(); |
| 61 virtual ~MessageFilter(); | |
| 62 | 61 |
| 63 // Called on the background thread to provide the filter with access to the | 62 // Called on the background thread to provide the filter with access to the |
| 64 // channel. Called when the IPC channel is initialized or when AddFilter | 63 // channel. Called when the IPC channel is initialized or when AddFilter |
| 65 // is called if the channel is already initialized. | 64 // is called if the channel is already initialized. |
| 66 virtual void OnFilterAdded(Channel* channel); | 65 virtual void OnFilterAdded(Channel* channel); |
| 67 | 66 |
| 68 // Called on the background thread when the filter has been removed from | 67 // Called on the background thread when the filter has been removed from |
| 69 // the ChannelProxy and when the Channel is closing. After a filter is | 68 // the ChannelProxy and when the Channel is closing. After a filter is |
| 70 // removed, it will not be called again. | 69 // removed, it will not be called again. |
| 71 virtual void OnFilterRemoved(); | 70 virtual void OnFilterRemoved(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 83 virtual void OnChannelClosing(); | 82 virtual void OnChannelClosing(); |
| 84 | 83 |
| 85 // Return true to indicate that the message was handled, or false to let | 84 // Return true to indicate that the message was handled, or false to let |
| 86 // the message be handled in the default way. | 85 // the message be handled in the default way. |
| 87 virtual bool OnMessageReceived(const Message& message); | 86 virtual bool OnMessageReceived(const Message& message); |
| 88 | 87 |
| 89 // Called when the message filter is about to be deleted. This gives | 88 // Called when the message filter is about to be deleted. This gives |
| 90 // derived classes the option of controlling which thread they're deleted | 89 // derived classes the option of controlling which thread they're deleted |
| 91 // on etc. | 90 // on etc. |
| 92 virtual void OnDestruct() const; | 91 virtual void OnDestruct() const; |
| 92 |
| 93 protected: |
| 94 virtual ~MessageFilter(); |
| 93 }; | 95 }; |
| 94 | 96 |
| 95 struct MessageFilterTraits { | 97 struct MessageFilterTraits { |
| 96 static void Destruct(const MessageFilter* filter) { | 98 static void Destruct(const MessageFilter* filter) { |
| 97 filter->OnDestruct(); | 99 filter->OnDestruct(); |
| 98 } | 100 } |
| 99 }; | 101 }; |
| 100 | 102 |
| 101 // Interface for a filter to be imposed on outgoing messages which can | 103 // Interface for a filter to be imposed on outgoing messages which can |
| 102 // re-write the message. Used mainly for testing. | 104 // re-write the message. Used mainly for testing. |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 281 |
| 280 OutgoingMessageFilter* outgoing_message_filter_; | 282 OutgoingMessageFilter* outgoing_message_filter_; |
| 281 | 283 |
| 282 // Whether the channel has been initialized. | 284 // Whether the channel has been initialized. |
| 283 bool did_init_; | 285 bool did_init_; |
| 284 }; | 286 }; |
| 285 | 287 |
| 286 } // namespace IPC | 288 } // namespace IPC |
| 287 | 289 |
| 288 #endif // IPC_IPC_CHANNEL_PROXY_H_ | 290 #endif // IPC_IPC_CHANNEL_PROXY_H_ |
| OLD | NEW |