| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_MESSAGE_PORT_MESSAGE_FILTER_H_ | 5 #ifndef CONTENT_BROWSER_MESSAGE_PORT_MESSAGE_FILTER_H_ |
| 6 #define CONTENT_BROWSER_MESSAGE_PORT_MESSAGE_FILTER_H_ | 6 #define CONTENT_BROWSER_MESSAGE_PORT_MESSAGE_FILTER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "content/common/content_export.h" | |
| 10 #include "content/public/browser/browser_message_filter.h" | 9 #include "content/public/browser/browser_message_filter.h" |
| 11 | 10 |
| 12 namespace content { | 11 namespace content { |
| 13 | 12 |
| 14 // Filter for MessagePort related IPC messages (creating and destroying a | 13 // Filter for MessagePort related IPC messages (creating and destroying a |
| 15 // MessagePort, sending a message via a MessagePort etc). | 14 // MessagePort, sending a message via a MessagePort etc). |
| 16 class CONTENT_EXPORT MessagePortMessageFilter : public BrowserMessageFilter { | 15 class MessagePortMessageFilter : public BrowserMessageFilter { |
| 17 public: | 16 public: |
| 18 typedef base::Callback<int(void)> NextRoutingIDCallback; | 17 typedef base::Callback<int(void)> NextRoutingIDCallback; |
| 19 | 18 |
| 20 // |next_routing_id| is owned by this object. It can be used up until | 19 // |next_routing_id| is owned by this object. It can be used up until |
| 21 // OnChannelClosing. | 20 // OnChannelClosing. |
| 22 explicit MessagePortMessageFilter(const NextRoutingIDCallback& callback); | 21 explicit MessagePortMessageFilter(const NextRoutingIDCallback& callback); |
| 23 | 22 |
| 24 // BrowserMessageFilter implementation. | 23 // BrowserMessageFilter implementation. |
| 25 virtual void OnChannelClosing() OVERRIDE; | 24 virtual void OnChannelClosing() OVERRIDE; |
| 26 virtual bool OnMessageReceived(const IPC::Message& message, | 25 virtual bool OnMessageReceived(const IPC::Message& message, |
| 27 bool* message_was_ok) OVERRIDE; | 26 bool* message_was_ok) OVERRIDE; |
| 28 virtual void OnDestruct() const OVERRIDE; | 27 virtual void OnDestruct() const OVERRIDE; |
| 29 | 28 |
| 30 int GetNextRoutingID(); | 29 int GetNextRoutingID(); |
| 31 | 30 |
| 32 protected: | |
| 33 // This is protected, so we can define sub classes for testing. | |
| 34 virtual ~MessagePortMessageFilter(); | |
| 35 | |
| 36 private: | 31 private: |
| 37 friend class BrowserThread; | 32 friend class BrowserThread; |
| 38 friend class base::DeleteHelper<MessagePortMessageFilter>; | 33 friend class base::DeleteHelper<MessagePortMessageFilter>; |
| 39 | 34 |
| 35 virtual ~MessagePortMessageFilter(); |
| 36 |
| 40 // Message handlers. | 37 // Message handlers. |
| 41 void OnCreateMessagePort(int* route_id, int* message_port_id); | 38 void OnCreateMessagePort(int* route_id, int* message_port_id); |
| 42 | 39 |
| 43 // This is guaranteed to be valid until OnChannelClosing is invoked, and it's | 40 // This is guaranteed to be valid until OnChannelClosing is invoked, and it's |
| 44 // not used after. | 41 // not used after. |
| 45 NextRoutingIDCallback next_routing_id_; | 42 NextRoutingIDCallback next_routing_id_; |
| 46 | 43 |
| 47 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePortMessageFilter); | 44 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePortMessageFilter); |
| 48 }; | 45 }; |
| 49 | 46 |
| 50 } // namespace content | 47 } // namespace content |
| 51 | 48 |
| 52 #endif // CONTENT_BROWSER_WORKER_MESSAGE_FILTER_H_ | 49 #endif // CONTENT_BROWSER_WORKER_MESSAGE_FILTER_H_ |
| OLD | NEW |