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 CHROME_BROWSER_BROWSER_MESSAGE_FILTER_H_ | 5 #ifndef CHROME_BROWSER_BROWSER_MESSAGE_FILTER_H_ |
6 #define CHROME_BROWSER_BROWSER_MESSAGE_FILTER_H_ | 6 #define CHROME_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 "chrome/browser/browser_thread.h" | 10 #include "chrome/browser/browser_thread.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 virtual void OverrideThreadForMessage(const IPC::Message& message, | 38 virtual void OverrideThreadForMessage(const IPC::Message& message, |
39 BrowserThread::ID* thread); | 39 BrowserThread::ID* thread); |
40 | 40 |
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 protected: | |
49 // Can be called on any thread, after OnChannelConnected is called. | 48 // Can be called on any thread, after OnChannelConnected is called. |
50 base::ProcessHandle peer_handle() { return peer_handle_; } | 49 base::ProcessHandle peer_handle() { return peer_handle_; } |
51 | 50 |
| 51 protected: |
52 // Call this if a message couldn't be deserialized. This kills the renderer. | 52 // Call this if a message couldn't be deserialized. This kills the renderer. |
53 // Can be called on any thread. | 53 // Can be called on any thread. |
54 void BadMessageReceived(uint32 msg_type); | 54 void BadMessageReceived(uint32 msg_type); |
55 | 55 |
56 private: | 56 private: |
57 // Dispatches a message to the derived class. | 57 // Dispatches a message to the derived class. |
58 bool DispatchMessage(const IPC::Message& message); | 58 bool DispatchMessage(const IPC::Message& message); |
59 | 59 |
60 IPC::Channel* channel_; | 60 IPC::Channel* channel_; |
61 base::ProcessHandle peer_handle_; | 61 base::ProcessHandle peer_handle_; |
62 }; | 62 }; |
63 | 63 |
64 #endif // CHROME_BROWSER_BROWSER_MESSAGE_FILTER_H_ | 64 #endif // CHROME_BROWSER_BROWSER_MESSAGE_FILTER_H_ |
OLD | NEW |