| Index: content/child/webmessageportchannel_impl.cc
|
| diff --git a/content/child/webmessageportchannel_impl.cc b/content/child/webmessageportchannel_impl.cc
|
| index 86e80fb09dbc78f651657feffcd5e74bca50ad8e..6f1fcb7e6b76c79e3ac8ccbc1d3bf00b1e42a47c 100644
|
| --- a/content/child/webmessageportchannel_impl.cc
|
| +++ b/content/child/webmessageportchannel_impl.cc
|
| @@ -59,6 +59,25 @@ WebMessagePortChannelImpl::~WebMessagePortChannelImpl() {
|
| ChildThread::current()->RemoveRoute(route_id_);
|
| }
|
|
|
| +// static
|
| +void WebMessagePortChannelImpl::ExtractMessagePortIDs(
|
| + WebMessagePortChannelArray* channels,
|
| + std::vector<int>* message_port_ids) {
|
| + DCHECK(message_port_ids->empty());
|
| + if (channels) {
|
| + message_port_ids->resize(channels->size());
|
| + // Extract the port IDs from the source array, then free it.
|
| + for (size_t i = 0; i < channels->size(); ++i) {
|
| + WebMessagePortChannelImpl* webchannel =
|
| + static_cast<WebMessagePortChannelImpl*>((*channels)[i]);
|
| + (*message_port_ids)[i] = webchannel->message_port_id();
|
| + webchannel->QueueMessages();
|
| + DCHECK((*message_port_ids)[i] != MSG_ROUTING_NONE);
|
| + }
|
| + delete channels;
|
| + }
|
| +}
|
| +
|
| void WebMessagePortChannelImpl::setClient(WebMessagePortChannelClient* client) {
|
| // Must lock here since client_ is called on the main thread.
|
| base::AutoLock auto_lock(lock_);
|
| @@ -98,19 +117,8 @@ void WebMessagePortChannelImpl::postMessage(
|
| void WebMessagePortChannelImpl::PostMessage(
|
| const base::string16& message,
|
| WebMessagePortChannelArray* channels) {
|
| - std::vector<int> message_port_ids(channels ? channels->size() : 0);
|
| - if (channels) {
|
| - // Extract the port IDs from the source array, then free it.
|
| - for (size_t i = 0; i < channels->size(); ++i) {
|
| - WebMessagePortChannelImpl* webchannel =
|
| - static_cast<WebMessagePortChannelImpl*>((*channels)[i]);
|
| - message_port_ids[i] = webchannel->message_port_id();
|
| - webchannel->QueueMessages();
|
| - DCHECK(message_port_ids[i] != MSG_ROUTING_NONE);
|
| - }
|
| - delete channels;
|
| - }
|
| -
|
| + std::vector<int> message_port_ids;
|
| + ExtractMessagePortIDs(channels, &message_port_ids);
|
| IPC::Message* msg = new MessagePortHostMsg_PostMessage(
|
| message_port_id_, message, message_port_ids);
|
| Send(msg);
|
|
|