Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: content/browser/navigator_connect/service_port_service_impl.cc

Issue 1224263007: Refactor browser side navigator.connect code to not use MessagePortService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@serviceport-serviceside
Patch Set: fix merge conflict Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // Second, pass of the actual to MessagePortService now ServicePort instances 113 navigator_connect_context_->PostMessage(
114 // are still backed by MessagePort. 114 port_id, MessagePortMessage(message.To<base::string16>()),
115 mps->PostMessage(port_id, MessagePortMessage(message.To<base::string16>()), 115 transferred_ports);
116 transferred_ports);
117 } 116 }
118 117
119 void ServicePortServiceImpl::ClosePort(int32_t port_id) { 118 void ServicePortServiceImpl::ClosePort(int32_t port_id) {
120 MessagePortService::GetInstance()->Destroy(port_id); 119 MessagePortService::GetInstance()->Destroy(port_id);
121 } 120 }
122 121
123 void ServicePortServiceImpl::OnConnectResult(const ConnectCallback& callback, 122 void ServicePortServiceImpl::OnConnectResult(const ConnectCallback& callback,
124 int message_port_id, 123 int message_port_id,
125 bool success) { 124 bool success) {
126 callback.Run(success ? SERVICE_PORT_CONNECT_RESULT_ACCEPT 125 callback.Run(success ? SERVICE_PORT_CONNECT_RESULT_ACCEPT
127 : SERVICE_PORT_CONNECT_RESULT_REJECT, 126 : SERVICE_PORT_CONNECT_RESULT_REJECT,
128 message_port_id); 127 message_port_id);
129 } 128 }
130 129
131 } // namespace content 130 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698