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