OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_BROWSER_BROWSER_MESSAGE_FILTER_H_ | 5 #ifndef CONTENT_BROWSER_BROWSER_MESSAGE_FILTER_H_ |
6 #define CONTENT_BROWSER_BROWSER_MESSAGE_FILTER_H_ | 6 #define CONTENT_BROWSER_BROWSER_MESSAGE_FILTER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/process.h" | 9 #include "base/process.h" |
10 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
11 #include "ipc/ipc_channel_proxy.h" | 11 #include "ipc/ipc_channel_proxy.h" |
12 | 12 |
13 // Base class for message filters in the browser process. You can receive and | 13 // Base class for message filters in the browser process. You can receive and |
14 // send messages on any thread. | 14 // send messages on any thread. |
15 class BrowserMessageFilter : public IPC::ChannelProxy::MessageFilter, | 15 class BrowserMessageFilter : public IPC::ChannelProxy::MessageFilter, |
16 public IPC::Message::Sender { | 16 public IPC::Message::Sender { |
17 public: | 17 public: |
18 BrowserMessageFilter(); | 18 BrowserMessageFilter(); |
19 virtual ~BrowserMessageFilter(); | 19 virtual ~BrowserMessageFilter(); |
20 | 20 |
21 // IPC::ChannelProxy::MessageFilter methods. If you override them, make sure | 21 // IPC::ChannelProxy::MessageFilter methods. If you override them, make sure |
22 // to call them as well. These are always called on the IO thread. | 22 // to call them as well. These are always called on the IO thread. |
23 virtual void OnFilterAdded(IPC::Channel* channel); | 23 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; |
24 virtual void OnChannelClosing(); | 24 virtual void OnChannelClosing() OVERRIDE; |
25 virtual void OnChannelConnected(int32 peer_pid); | 25 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
26 // DON'T OVERRIDE THIS! Override the other version below. | 26 // DON'T OVERRIDE THIS! Override the other version below. |
27 virtual bool OnMessageReceived(const IPC::Message& message); | 27 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
28 | 28 |
29 // IPC::Message::Sender implementation. Can be called on any thread. Can't | 29 // IPC::Message::Sender implementation. Can be called on any thread. Can't |
30 // send sync messages (since we don't want to block the browser on any other | 30 // send sync messages (since we don't want to block the browser on any other |
31 // process). | 31 // process). |
32 virtual bool Send(IPC::Message* message); | 32 virtual bool Send(IPC::Message* message); |
33 | 33 |
34 // If you want the given message to be dispatched to your OnMessageReceived on | 34 // If you want the given message to be dispatched to your OnMessageReceived on |
35 // a different thread, change |thread| to the id of the target thread. | 35 // a different thread, change |thread| to the id of the target thread. |
36 // If you don't handle this message, or want to keep it on the IO thread, do | 36 // If you don't handle this message, or want to keep it on the IO thread, do |
37 // nothing. | 37 // nothing. |
(...skipping 22 matching lines...) Expand all Loading... |
60 | 60 |
61 private: | 61 private: |
62 // Dispatches a message to the derived class. | 62 // Dispatches a message to the derived class. |
63 bool DispatchMessage(const IPC::Message& message); | 63 bool DispatchMessage(const IPC::Message& message); |
64 | 64 |
65 IPC::Channel* channel_; | 65 IPC::Channel* channel_; |
66 base::ProcessHandle peer_handle_; | 66 base::ProcessHandle peer_handle_; |
67 }; | 67 }; |
68 | 68 |
69 #endif // CONTENT_BROWSER_BROWSER_MESSAGE_FILTER_H_ | 69 #endif // CONTENT_BROWSER_BROWSER_MESSAGE_FILTER_H_ |
OLD | NEW |