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" |
(...skipping 30 matching lines...) Expand all Loading... |
41 // Override this to receive messages. | 41 // Override this to receive messages. |
42 // Your function will normally be called on the IO thread. However, if your | 42 // Your function will normally be called on the IO thread. However, if your |
43 // OverrideThreadForMessage modifies the thread used to dispatch the message, | 43 // OverrideThreadForMessage modifies the thread used to dispatch the message, |
44 // your function will be called on the requested thread. | 44 // your function will be called on the requested thread. |
45 virtual bool OnMessageReceived(const IPC::Message& message, | 45 virtual bool OnMessageReceived(const IPC::Message& message, |
46 bool* message_was_ok) = 0; | 46 bool* message_was_ok) = 0; |
47 | 47 |
48 // Can be called on any thread, after OnChannelConnected is called. | 48 // Can be called on any thread, after OnChannelConnected is called. |
49 base::ProcessHandle peer_handle() { return peer_handle_; } | 49 base::ProcessHandle peer_handle() { return peer_handle_; } |
50 | 50 |
| 51 // Checks that the given message can be dispatched on the UI thread, depending |
| 52 // on the platform. If not, returns false and an error ot the sender. |
| 53 static bool MessageCanBeDispatchedOnUI(const IPC::Message& message, |
| 54 IPC::Message::Sender* sender); |
| 55 |
51 protected: | 56 protected: |
52 // Call this if a message couldn't be deserialized. This kills the renderer. | 57 // Call this if a message couldn't be deserialized. This kills the renderer. |
53 // Can be called on any thread. | 58 // Can be called on any thread. |
54 virtual void BadMessageReceived(); | 59 virtual void BadMessageReceived(); |
55 | 60 |
56 private: | 61 private: |
57 // Dispatches a message to the derived class. | 62 // Dispatches a message to the derived class. |
58 bool DispatchMessage(const IPC::Message& message); | 63 bool DispatchMessage(const IPC::Message& message); |
59 | 64 |
60 IPC::Channel* channel_; | 65 IPC::Channel* channel_; |
61 base::ProcessHandle peer_handle_; | 66 base::ProcessHandle peer_handle_; |
62 }; | 67 }; |
63 | 68 |
64 #endif // CONTENT_BROWSER_BROWSER_MESSAGE_FILTER_H_ | 69 #endif // CONTENT_BROWSER_BROWSER_MESSAGE_FILTER_H_ |
OLD | NEW |