| 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 #include "content/browser/message_port_message_filter.h" | 5 #include "content/browser/message_port_message_filter.h" |
| 6 | 6 |
| 7 #include "content/browser/message_port_service.h" | 7 #include "content/browser/message_port_service.h" |
| 8 #include "content/common/message_port_messages.h" | 8 #include "content/common/message_port_messages.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 | 11 |
| 12 MessagePortMessageFilter::MessagePortMessageFilter( | 12 MessagePortMessageFilter::MessagePortMessageFilter( |
| 13 const NextRoutingIDCallback& callback) | 13 const NextRoutingIDCallback& callback) |
| 14 : BrowserMessageFilter(MessagePortMsgStart), | 14 : BrowserMessageFilter(MessagePortMsgStart), |
| 15 next_routing_id_(callback) { | 15 next_routing_id_(callback) { |
| 16 } | 16 } |
| 17 | 17 |
| 18 MessagePortMessageFilter::~MessagePortMessageFilter() { | 18 MessagePortMessageFilter::~MessagePortMessageFilter() { |
| 19 } | 19 } |
| 20 | 20 |
| 21 void MessagePortMessageFilter::OnChannelClosing() { | 21 void MessagePortMessageFilter::OnChannelClosing() { |
| 22 MessagePortService::GetInstance()->OnMessagePortMessageFilterClosing(this); | 22 MessagePortService::GetInstance()->OnMessagePortMessageFilterClosing(this); |
| 23 } | 23 } |
| 24 | 24 |
| 25 bool MessagePortMessageFilter::OnMessageReceived(const IPC::Message& message, | 25 bool MessagePortMessageFilter::OnMessageReceived(const IPC::Message& message) { |
| 26 bool* message_was_ok) { | |
| 27 bool handled = true; | 26 bool handled = true; |
| 28 IPC_BEGIN_MESSAGE_MAP_EX(MessagePortMessageFilter, message, *message_was_ok) | 27 IPC_BEGIN_MESSAGE_MAP(MessagePortMessageFilter, message) |
| 29 IPC_MESSAGE_HANDLER(MessagePortHostMsg_CreateMessagePort, | 28 IPC_MESSAGE_HANDLER(MessagePortHostMsg_CreateMessagePort, |
| 30 OnCreateMessagePort) | 29 OnCreateMessagePort) |
| 31 IPC_MESSAGE_FORWARD(MessagePortHostMsg_DestroyMessagePort, | 30 IPC_MESSAGE_FORWARD(MessagePortHostMsg_DestroyMessagePort, |
| 32 MessagePortService::GetInstance(), | 31 MessagePortService::GetInstance(), |
| 33 MessagePortService::Destroy) | 32 MessagePortService::Destroy) |
| 34 IPC_MESSAGE_FORWARD(MessagePortHostMsg_Entangle, | 33 IPC_MESSAGE_FORWARD(MessagePortHostMsg_Entangle, |
| 35 MessagePortService::GetInstance(), | 34 MessagePortService::GetInstance(), |
| 36 MessagePortService::Entangle) | 35 MessagePortService::Entangle) |
| 37 IPC_MESSAGE_FORWARD(MessagePortHostMsg_PostMessage, | 36 IPC_MESSAGE_FORWARD(MessagePortHostMsg_PostMessage, |
| 38 MessagePortService::GetInstance(), | 37 MessagePortService::GetInstance(), |
| 39 MessagePortService::PostMessage) | 38 MessagePortService::PostMessage) |
| 40 IPC_MESSAGE_FORWARD(MessagePortHostMsg_QueueMessages, | 39 IPC_MESSAGE_FORWARD(MessagePortHostMsg_QueueMessages, |
| 41 MessagePortService::GetInstance(), | 40 MessagePortService::GetInstance(), |
| 42 MessagePortService::QueueMessages) | 41 MessagePortService::QueueMessages) |
| 43 IPC_MESSAGE_FORWARD(MessagePortHostMsg_SendQueuedMessages, | 42 IPC_MESSAGE_FORWARD(MessagePortHostMsg_SendQueuedMessages, |
| 44 MessagePortService::GetInstance(), | 43 MessagePortService::GetInstance(), |
| 45 MessagePortService::SendQueuedMessages) | 44 MessagePortService::SendQueuedMessages) |
| 46 IPC_MESSAGE_UNHANDLED(handled = false) | 45 IPC_MESSAGE_UNHANDLED(handled = false) |
| 47 IPC_END_MESSAGE_MAP_EX() | 46 IPC_END_MESSAGE_MAP() |
| 48 | 47 |
| 49 return handled; | 48 return handled; |
| 50 } | 49 } |
| 51 | 50 |
| 52 void MessagePortMessageFilter::OnDestruct() const { | 51 void MessagePortMessageFilter::OnDestruct() const { |
| 53 BrowserThread::DeleteOnIOThread::Destruct(this); | 52 BrowserThread::DeleteOnIOThread::Destruct(this); |
| 54 } | 53 } |
| 55 | 54 |
| 56 int MessagePortMessageFilter::GetNextRoutingID() { | 55 int MessagePortMessageFilter::GetNextRoutingID() { |
| 57 return next_routing_id_.Run(); | 56 return next_routing_id_.Run(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 73 } | 72 } |
| 74 } | 73 } |
| 75 | 74 |
| 76 void MessagePortMessageFilter::OnCreateMessagePort(int *route_id, | 75 void MessagePortMessageFilter::OnCreateMessagePort(int *route_id, |
| 77 int* message_port_id) { | 76 int* message_port_id) { |
| 78 *route_id = next_routing_id_.Run(); | 77 *route_id = next_routing_id_.Run(); |
| 79 MessagePortService::GetInstance()->Create(*route_id, this, message_port_id); | 78 MessagePortService::GetInstance()->Create(*route_id, this, message_port_id); |
| 80 } | 79 } |
| 81 | 80 |
| 82 } // namespace content | 81 } // namespace content |
| OLD | NEW |