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

Unified Diff: content/browser/message_port_service.cc

Issue 944443003: Step two of optionally sending messages to/from message ports as base::Value. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@n-c-message-as-values-take2
Patch Set: use auto where it makes sense Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/message_port_service.cc
diff --git a/content/browser/message_port_service.cc b/content/browser/message_port_service.cc
index 597b1906f0762d519bfefce7d67f23d9b9b12351..915ae483d3194cfdaff3501b56e1059639d386cf 100644
--- a/content/browser/message_port_service.cc
+++ b/content/browser/message_port_service.cc
@@ -134,7 +134,7 @@ void MessagePortService::Entangle(int local_message_port_id,
void MessagePortService::PostMessage(
int sender_message_port_id,
const MessagePortMessage& message,
- const std::vector<int>& sent_message_port_ids) {
+ const std::vector<TransferredMessagePort>& sent_message_ports) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!message_ports_.count(sender_message_port_id)) {
NOTREACHED();
@@ -151,40 +151,35 @@ void MessagePortService::PostMessage(
return;
}
- PostMessageTo(entangled_message_port_id, message, sent_message_port_ids);
+ PostMessageTo(entangled_message_port_id, message, sent_message_ports);
}
void MessagePortService::PostMessageTo(
int message_port_id,
const MessagePortMessage& message,
- const std::vector<int>& sent_message_port_ids) {
+ const std::vector<TransferredMessagePort>& sent_message_ports) {
if (!message_ports_.count(message_port_id)) {
NOTREACHED();
return;
}
- for (size_t i = 0; i < sent_message_port_ids.size(); ++i) {
- if (!message_ports_.count(sent_message_port_ids[i])) {
+ for (size_t i = 0; i < sent_message_ports.size(); ++i) {
+ if (!message_ports_.count(sent_message_ports[i].id)) {
NOTREACHED();
return;
}
}
MessagePort& entangled_port = message_ports_[message_port_id];
-
- std::vector<MessagePort*> sent_ports(sent_message_port_ids.size());
- for (size_t i = 0; i < sent_message_port_ids.size(); ++i)
- sent_ports[i] = &message_ports_[sent_message_port_ids[i]];
-
if (entangled_port.queue_messages()) {
// If the target port is currently holding messages because the destination
// renderer isn't available yet, all message ports being sent should also be
// put in this state.
if (entangled_port.hold_messages_for_destination) {
- for (int sent_message_port_id : sent_message_port_ids)
- HoldMessages(sent_message_port_id);
+ for (const auto& port : sent_message_ports)
+ HoldMessages(port.id);
}
entangled_port.queued_messages.push_back(
- std::make_pair(message, sent_message_port_ids));
+ std::make_pair(message, sent_message_ports));
return;
}
@@ -195,7 +190,7 @@ void MessagePortService::PostMessageTo(
// Now send the message to the entangled port.
entangled_port.delegate->SendMessage(entangled_port.route_id, message,
- sent_message_port_ids);
+ sent_message_ports);
}
void MessagePortService::QueueMessages(int message_port_id) {
@@ -231,8 +226,8 @@ void MessagePortService::SendQueuedMessages(
// all ports in messages being sent to the port should also be put on hold.
if (port.hold_messages_for_destination) {
for (const auto& message : queued_messages)
- for (int sent_message_port_id : message.second)
- HoldMessages(sent_message_port_id);
+ for (const TransferredMessagePort& sent_port : message.second)
+ HoldMessages(sent_port.id);
}
port.queued_messages.insert(port.queued_messages.begin(),
@@ -272,8 +267,8 @@ void MessagePortService::HoldMessages(int message_port_id) {
// Any ports in messages currently in the queue should also be put on hold.
for (const auto& message : message_ports_[message_port_id].queued_messages)
- for (int sent_message_port_id : message.second)
- HoldMessages(sent_message_port_id);
+ for (const TransferredMessagePort& sent_port : message.second)
+ HoldMessages(sent_port.id);
message_ports_[message_port_id].hold_messages_for_destination = true;
}
@@ -292,8 +287,8 @@ void MessagePortService::ClosePort(int message_port_id) {
// First close any message ports in the queue for this message port.
for (const auto& message : message_ports_[message_port_id].queued_messages)
- for (int sent_message_port_id : message.second)
- ClosePort(sent_message_port_id);
+ for (const TransferredMessagePort& sent_port : message.second)
+ ClosePort(sent_port.id);
Erase(message_port_id);
}
« no previous file with comments | « content/browser/message_port_service.h ('k') | content/browser/navigator_connect/navigator_connect_context_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698