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

Unified Diff: content/renderer/gpu/compositor_forwarding_message_filter.h

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: content/renderer/gpu/compositor_forwarding_message_filter.h
diff --git a/content/renderer/gpu/compositor_forwarding_message_filter.h b/content/renderer/gpu/compositor_forwarding_message_filter.h
new file mode 100644
index 0000000000000000000000000000000000000000..011ae4fe7c6b81948ac63d748dfa343f3e8b12c4
--- /dev/null
+++ b/content/renderer/gpu/compositor_forwarding_message_filter.h
@@ -0,0 +1,77 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_GPU_COMPOSITOR_FORWARDING_MESSAGE_FILTER_H_
+#define CONTENT_RENDERER_GPU_COMPOSITOR_FORWARDING_MESSAGE_FILTER_H_
+
+#include <map>
+#include <set>
+
+#include "base/bind.h"
+#include "base/callback_forward.h"
+#include "base/synchronization/lock.h"
+#include "base/task_runner.h"
+#include "content/common/content_export.h"
+#include "ipc/message_filter.h"
+
+namespace content {
+
+// 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 type. To route these messages,
+// add a Handler to the filter.
+//
+// The user of this class implements CompositorForwardingMessageFilter::Handler,
+// which will receive the intercepted messages, on the specified target thread.
+// The caller must ensure that each handler in |multi_handlers_| outlives the
+// lifetime of the filter.
+// User can add multiple handlers for specific routing id. When messages are
+// arrived, all handlers in |multi_handlers_| for routing id will be executed.
brianderson 2014/10/24 20:46:58 are arrived -> have arrived
simonhong 2014/10/29 14:47:14 Done.
+class CONTENT_EXPORT CompositorForwardingMessageFilter
+ : public IPC::MessageFilter {
+ public:
+ static CompositorForwardingMessageFilter* Create(
+ base::TaskRunner* target_task_runner);
+ // The handler is invoked on the thread associated with
+ // |target_task_runner_| with messages that were intercepted by this filter.
+ typedef base::Callback<void(const IPC::Message&)> Handler;
+
+ // Define the message handler to be filtered.
+ void AddRoute(int routing_id, const Handler& handler);
+ void RemoveRoute(int routing_id, const Handler& handler);
+
+ // MessageFilter methods:
+ virtual bool OnMessageReceived(const IPC::Message& message) override;
+
+ protected:
+ // This filter will intercept |message_ids_to_filter| and post
+ // them to the provided |target_task_runner|, where they will be given
+ // to all handlers in the |multi_handlers_|.
+ CompositorForwardingMessageFilter(
+ const uint32* message_ids_to_filter,
+ size_t num_message_ids_to_filter,
+ base::TaskRunner* target_task_runner);
+
+ virtual ~CompositorForwardingMessageFilter();
+
+ private:
+ 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_;
+
+ // Protects access to |multi_handlers_|.
+ base::Lock handlers_lock_;
+
+ // Maps the routing_id for which messages should be filtered and handlers
+ // which will be routed.
+ std::multimap<int, Handler> multi_handlers_;
+
+ DISALLOW_COPY_AND_ASSIGN(CompositorForwardingMessageFilter);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_GPU_COMPOSITOR_FORWARDING_MESSAGE_FILTER_H_

Powered by Google App Engine
This is Rietveld 408576698