summaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authornduca@chromium.org <nduca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-13 23:24:35 +0000
committernduca@chromium.org <nduca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-13 23:24:35 +0000
commit1842fe2422e552fe024b8975cf7e611d10434c44 (patch)
tree642bb3067e7a903bc1aa9687b885adbf7f9afb56 /ipc
parentb1402a5ad552386dbeeef477dfa351cd453d5793 (diff)
downloadchromium_src-1842fe2422e552fe024b8975cf7e611d10434c44.zip
chromium_src-1842fe2422e552fe024b8975cf7e611d10434c44.tar.gz
chromium_src-1842fe2422e552fe024b8975cf7e611d10434c44.tar.bz2
Creates the WebCompositorOutputSurface, which is the new mechanism for rendering interactions between the compositor and RenderWidgetHost.
As part of this, we plumb vsync information to the compositor. The new IPC::ForwardingMessageFilter is modified to have route-specific handlers rather than a global handler. This simplifies message routing considerably. BUG=129674 Review URL: https://chromiumcodereview.appspot.com/10798006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151387 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc')
-rw-r--r--ipc/ipc_forwarding_message_filter.cc36
-rw-r--r--ipc/ipc_forwarding_message_filter.h18
2 files changed, 23 insertions, 31 deletions
diff --git a/ipc/ipc_forwarding_message_filter.cc b/ipc/ipc_forwarding_message_filter.cc
index 48f6e5f..d886706 100644
--- a/ipc/ipc_forwarding_message_filter.cc
+++ b/ipc/ipc_forwarding_message_filter.cc
@@ -12,24 +12,22 @@ namespace IPC {
ForwardingMessageFilter::ForwardingMessageFilter(
const uint32* message_ids_to_filter,
size_t num_message_ids_to_filter,
- base::TaskRunner* target_task_runner,
- const Handler& handler)
- : target_task_runner_(target_task_runner),
- handler_(handler) {
+ base::TaskRunner* target_task_runner)
+ : target_task_runner_(target_task_runner) {
DCHECK(target_task_runner_);
- DCHECK(!handler_.is_null());
for (size_t i = 0; i < num_message_ids_to_filter; i++)
message_ids_to_filter_.insert(message_ids_to_filter[i]);
}
-void ForwardingMessageFilter::AddRoute(int routing_id) {
- base::AutoLock locked(routes_lock_);
- routes_.insert(routing_id);
+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));
}
void ForwardingMessageFilter::RemoveRoute(int routing_id) {
- base::AutoLock locked(routes_lock_);
- routes_.erase(routing_id);
+ base::AutoLock locked(handlers_lock_);
+ handlers_.erase(routing_id);
}
bool ForwardingMessageFilter::OnMessageReceived(const Message& message) {
@@ -37,24 +35,22 @@ bool ForwardingMessageFilter::OnMessageReceived(const Message& message) {
message_ids_to_filter_.end())
return false;
+
+ Handler handler;
+
{
- base::AutoLock locked(routes_lock_);
- if (routes_.find(message.routing_id()) == routes_.end())
+ base::AutoLock locked(handlers_lock_);
+ std::map<int, Handler>::iterator it = handlers_.find(message.routing_id());
+ if (it == handlers_.end())
return false;
+ handler = it->second;
}
- target_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&ForwardingMessageFilter::ForwardToHandler, this, message));
+ target_task_runner_->PostTask(FROM_HERE, base::Bind(handler, message));
return true;
}
ForwardingMessageFilter::~ForwardingMessageFilter() {
}
-void ForwardingMessageFilter::ForwardToHandler(const Message& message) {
- DCHECK(target_task_runner_->RunsTasksOnCurrentThread());
- handler_.Run(message);
-}
-
} // namespace IPC
diff --git a/ipc/ipc_forwarding_message_filter.h b/ipc/ipc_forwarding_message_filter.h
index 5b404c5..919a44d 100644
--- a/ipc/ipc_forwarding_message_filter.h
+++ b/ipc/ipc_forwarding_message_filter.h
@@ -5,6 +5,7 @@
#ifndef IPC_IPC_FORWARDING_MESSAGE_FILTER_H_
#define IPC_IPC_FORWARDING_MESSAGE_FILTER_H_
+#include <map>
#include <set>
#include "base/bind.h"
@@ -17,9 +18,8 @@ namespace IPC {
// This class can be used to intercept routed messages and
// deliver them to a different task runner than they would otherwise
-// be sent. Messages are filtered based on
-// based on routing_id as well as type (see message_ids_to_filter and AddRoute
-// and RemoveRoute).
+// be sent. Messages are filtered based on type. To route these messages,
+// add a MessageRouter to the handler.
//
// The user of this class implements ForwardingMessageFilter::Client,
// which will receive the intercepted messages, on the specified target thread.
@@ -38,11 +38,10 @@ class IPC_EXPORT ForwardingMessageFilter : public ChannelProxy::MessageFilter {
ForwardingMessageFilter(
const uint32* message_ids_to_filter,
size_t num_message_ids_to_filter,
- base::TaskRunner* target_task_runner,
- const Handler& handler);
+ base::TaskRunner* target_task_runner);
// Define the message routes to be filtered.
- void AddRoute(int routing_id);
+ void AddRoute(int routing_id, const Handler& handler);
void RemoveRoute(int routing_id);
// ChannelProxy::MessageFilter methods:
@@ -52,20 +51,17 @@ class IPC_EXPORT ForwardingMessageFilter : public ChannelProxy::MessageFilter {
friend class ChannelProxy::MessageFilter;
virtual ~ForwardingMessageFilter();
- void ForwardToHandler(const Message& message);
-
std::set<int> message_ids_to_filter_;
// The handler_ only gets Run on the thread corresponding to
// target_task_runner_.
scoped_refptr<base::TaskRunner> target_task_runner_;
- Handler handler_;
// Protects access to routes_.
- base::Lock routes_lock_;
+ base::Lock handlers_lock_;
// Indicates the routing_ids for which messages should be filtered.
- std::set<int> routes_;
+ std::map<int, Handler> handlers_;
DISALLOW_COPY_AND_ASSIGN(ForwardingMessageFilter);
};