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

Unified Diff: ipc/ipc_forwarding_message_filter.cc

Issue 619843002: cc: Make separate interface for BeginFrame ipc from OutputSurface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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: ipc/ipc_forwarding_message_filter.cc
diff --git a/ipc/ipc_forwarding_message_filter.cc b/ipc/ipc_forwarding_message_filter.cc
index 9857bdf67dcde3b952b733dc46404162678244eb..60f56634e6e47ffddd0fdd2cc5a72df84959e600 100644
--- a/ipc/ipc_forwarding_message_filter.cc
+++ b/ipc/ipc_forwarding_message_filter.cc
@@ -23,12 +23,20 @@ ForwardingMessageFilter::ForwardingMessageFilter(
void ForwardingMessageFilter::AddRoute(int routing_id, const Handler& handler) {
DCHECK(!handler.is_null());
base::AutoLock locked(handlers_lock_);
- handlers_.insert(std::make_pair(routing_id, handler));
+ multi_handlers_.insert(std::make_pair(routing_id, handler));
}
-void ForwardingMessageFilter::RemoveRoute(int routing_id) {
+void ForwardingMessageFilter::RemoveRoute(int routing_id,
+ const Handler& handler) {
base::AutoLock locked(handlers_lock_);
- handlers_.erase(routing_id);
+ auto handlers = multi_handlers_.equal_range(routing_id);
+ for (auto it = handlers.first; it != handlers.second; ++it) {
+ if (it->second.Equals(handler)) {
+ multi_handlers_.erase(it);
+ return;
+ }
+ }
+ NOTREACHED();
}
bool ForwardingMessageFilter::OnMessageReceived(const Message& message) {
@@ -36,18 +44,16 @@ bool ForwardingMessageFilter::OnMessageReceived(const Message& message) {
message_ids_to_filter_.end())
return false;
-
- Handler handler;
-
{
base::AutoLock locked(handlers_lock_);
- std::map<int, Handler>::iterator it = handlers_.find(message.routing_id());
- if (it == handlers_.end())
+ auto handlers = multi_handlers_.equal_range(message.routing_id());
+ if (handlers.first == handlers.second)
return false;
- handler = it->second;
+
+ for (auto it = handlers.first; it != handlers.second; ++it)
+ target_task_runner_->PostTask(FROM_HERE, base::Bind(it->second, message));
}
- target_task_runner_->PostTask(FROM_HERE, base::Bind(handler, message));
return true;
}

Powered by Google App Engine
This is Rietveld 408576698