| 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 CONTENT_PUBLIC_BROWSER_BROWSER_MESSAGE_FILTER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_MESSAGE_FILTER_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_BROWSER_MESSAGE_FILTER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_BROWSER_MESSAGE_FILTER_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/process/process.h" | 9 #include "base/process/process.h" |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 : public base::RefCountedThreadSafe< | 32 : public base::RefCountedThreadSafe< |
| 33 BrowserMessageFilter, BrowserMessageFilterTraits>, | 33 BrowserMessageFilter, BrowserMessageFilterTraits>, |
| 34 public IPC::Sender { | 34 public IPC::Sender { |
| 35 public: | 35 public: |
| 36 explicit BrowserMessageFilter(uint32 message_class_to_filter); | 36 explicit BrowserMessageFilter(uint32 message_class_to_filter); |
| 37 BrowserMessageFilter(const uint32* message_classes_to_filter, | 37 BrowserMessageFilter(const uint32* message_classes_to_filter, |
| 38 size_t num_message_classes_to_filter); | 38 size_t num_message_classes_to_filter); |
| 39 | 39 |
| 40 // These match the corresponding IPC::MessageFilter methods and are always | 40 // These match the corresponding IPC::MessageFilter methods and are always |
| 41 // called on the IO thread. | 41 // called on the IO thread. |
| 42 virtual void OnFilterAdded(IPC::Channel* channel) {} | 42 virtual void OnFilterAdded(IPC::Sender* sender) {} |
| 43 virtual void OnFilterRemoved() {} | 43 virtual void OnFilterRemoved() {} |
| 44 virtual void OnChannelClosing() {} | 44 virtual void OnChannelClosing() {} |
| 45 virtual void OnChannelConnected(int32 peer_pid) {} | 45 virtual void OnChannelConnected(int32 peer_pid) {} |
| 46 | 46 |
| 47 // Called when the message filter is about to be deleted. This gives | 47 // Called when the message filter is about to be deleted. This gives |
| 48 // derived classes the option of controlling which thread they're deleted | 48 // derived classes the option of controlling which thread they're deleted |
| 49 // on etc. | 49 // on etc. |
| 50 virtual void OnDestruct() const; | 50 virtual void OnDestruct() const; |
| 51 | 51 |
| 52 // IPC::Sender implementation. Can be called on any thread. Can't send sync | 52 // IPC::Sender implementation. Can be called on any thread. Can't send sync |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // friends above. This is only guaranteed to be valid on creation, after that | 116 // friends above. This is only guaranteed to be valid on creation, after that |
| 117 // this class could outlive the filter. | 117 // this class could outlive the filter. |
| 118 IPC::MessageFilter* GetFilter(); | 118 IPC::MessageFilter* GetFilter(); |
| 119 | 119 |
| 120 // This implements IPC::MessageFilter so that we can hide that from child | 120 // This implements IPC::MessageFilter so that we can hide that from child |
| 121 // classes. Internal keeps a reference to this class, which is why there's a | 121 // classes. Internal keeps a reference to this class, which is why there's a |
| 122 // weak pointer back. This class could outlive Internal based on what the | 122 // weak pointer back. This class could outlive Internal based on what the |
| 123 // child class does in its OnDestruct method. | 123 // child class does in its OnDestruct method. |
| 124 Internal* internal_; | 124 Internal* internal_; |
| 125 | 125 |
| 126 IPC::Channel* channel_; | 126 IPC::Sender* sender_; |
| 127 base::ProcessId peer_pid_; | 127 base::ProcessId peer_pid_; |
| 128 | 128 |
| 129 std::vector<uint32> message_classes_to_filter_; | 129 std::vector<uint32> message_classes_to_filter_; |
| 130 | 130 |
| 131 #if defined(OS_WIN) | 131 #if defined(OS_WIN) |
| 132 base::Lock peer_handle_lock_; | 132 base::Lock peer_handle_lock_; |
| 133 base::ProcessHandle peer_handle_; | 133 base::ProcessHandle peer_handle_; |
| 134 #endif | 134 #endif |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 struct BrowserMessageFilterTraits { | 137 struct BrowserMessageFilterTraits { |
| 138 static void Destruct(const BrowserMessageFilter* filter) { | 138 static void Destruct(const BrowserMessageFilter* filter) { |
| 139 filter->OnDestruct(); | 139 filter->OnDestruct(); |
| 140 } | 140 } |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 } // namespace content | 143 } // namespace content |
| 144 | 144 |
| 145 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_MESSAGE_FILTER_H_ | 145 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_MESSAGE_FILTER_H_ |
| OLD | NEW |