| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/navigator_connect/service_port_service_impl.h" | 5 #include "content/browser/navigator_connect/service_port_service_impl.h" |
| 6 | 6 |
| 7 #include "content/browser/message_port_message_filter.h" | 7 #include "content/browser/message_port_message_filter.h" |
| 8 #include "content/browser/message_port_service.h" | 8 #include "content/browser/message_port_service.h" |
| 9 #include "content/browser/navigator_connect/navigator_connect_context_impl.h" | 9 #include "content/browser/navigator_connect/navigator_connect_context_impl.h" |
| 10 #include "content/common/service_port_type_converters.h" | 10 #include "content/common/service_port_type_converters.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 std::vector<TransferredMessagePort> transferred_ports = | 103 std::vector<TransferredMessagePort> transferred_ports = |
| 104 ports.To<std::vector<TransferredMessagePort>>(); | 104 ports.To<std::vector<TransferredMessagePort>>(); |
| 105 | 105 |
| 106 MessagePortService* mps = MessagePortService::GetInstance(); | 106 MessagePortService* mps = MessagePortService::GetInstance(); |
| 107 // First, call QueueMessages for all transferred ports, since the ports | 107 // First, call QueueMessages for all transferred ports, since the ports |
| 108 // haven't sent their own IPC for that. | 108 // haven't sent their own IPC for that. |
| 109 for (const TransferredMessagePort& port : transferred_ports) { | 109 for (const TransferredMessagePort& port : transferred_ports) { |
| 110 mps->QueueMessages(port.id); | 110 mps->QueueMessages(port.id); |
| 111 } | 111 } |
| 112 | 112 |
| 113 navigator_connect_context_->PostMessage( | 113 // Second, pass of the actual to MessagePortService now ServicePort instances |
| 114 port_id, MessagePortMessage(message.To<base::string16>()), | 114 // are still backed by MessagePort. |
| 115 transferred_ports); | 115 mps->PostMessage(port_id, MessagePortMessage(message.To<base::string16>()), |
| 116 transferred_ports); |
| 116 } | 117 } |
| 117 | 118 |
| 118 void ServicePortServiceImpl::ClosePort(int32_t port_id) { | 119 void ServicePortServiceImpl::ClosePort(int32_t port_id) { |
| 119 MessagePortService::GetInstance()->Destroy(port_id); | 120 MessagePortService::GetInstance()->Destroy(port_id); |
| 120 } | 121 } |
| 121 | 122 |
| 122 void ServicePortServiceImpl::OnConnectResult(const ConnectCallback& callback, | 123 void ServicePortServiceImpl::OnConnectResult(const ConnectCallback& callback, |
| 123 int message_port_id, | 124 int message_port_id, |
| 124 bool success) { | 125 bool success) { |
| 125 callback.Run(success ? SERVICE_PORT_CONNECT_RESULT_ACCEPT | 126 callback.Run(success ? SERVICE_PORT_CONNECT_RESULT_ACCEPT |
| 126 : SERVICE_PORT_CONNECT_RESULT_REJECT, | 127 : SERVICE_PORT_CONNECT_RESULT_REJECT, |
| 127 message_port_id); | 128 message_port_id); |
| 128 } | 129 } |
| 129 | 130 |
| 130 } // namespace content | 131 } // namespace content |
| OLD | NEW |