Chromium Code Reviews| Index: content/child/cross_thread_message_filter.h |
| diff --git a/content/child/cross_thread_message_filter.h b/content/child/cross_thread_message_filter.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..27391e0537bb6adcdb8cd8186cc8aa6f84074296 |
| --- /dev/null |
| +++ b/content/child/cross_thread_message_filter.h |
| @@ -0,0 +1,60 @@ |
| +// Copyright 2013 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_CHILD_CROSS_THREAD_MESSAGE_FILTER_H_ |
| +#define CONTENT_CHILD_CROSS_THREAD_MESSAGE_FILTER_H_ |
| + |
| +#include "ipc/ipc_channel_proxy.h" |
| + |
| +namespace content { |
| + |
| +// A base class of cross-thread message filter for dispatching messages |
| +// to blink's worker threads via WorkerTaskRunner. |
|
jam
2013/11/08 19:51:59
nit: no need to mention blink here, this class can
kinuko
2013/11/15 14:40:36
Done.
|
| +class CrossThreadMessageFilter |
|
jam
2013/11/08 19:51:59
nit: I think ChildMessageFilter is sufficient, tha
kinuko
2013/11/15 14:40:36
Ok, done. (scherkus@, hope it's ok that I'm steali
scherkus (not reviewing)
2013/11/15 19:12:19
go for it! I don't have the bandwidth at the momen
|
| + : public base::RefCountedThreadSafe<CrossThreadMessageFilter> { |
| + public: |
| + // If implementors want to run OnMessageReceived on a different thread |
| + // it should set |thread_id| to a thee thread ID and return true. |
| + // 0 thread_id indicates OnMessageReceived should be dispatched to |
| + // the main child thread. |
| + // Returning false indicates OnMessageReceived should be called on the |
| + // IPC thread. |
| + virtual bool OverrideThreadIDForMessage( |
| + const IPC::Message& msg, |
| + int* thread_id) = 0; |
| + |
| + // If OverrideThreadIDForMessage returned true this is called on the |
| + // target thread that is returned by OverrideThreadIDForMessage. |
| + virtual bool OnMessageReceived(const IPC::Message& msg) = 0; |
| + |
| + // This method is called when WorkerTaskRunner::PostTask() returned false |
| + // for the target thread. Note that there's still a listtle chance that |
| + // PostTask() returns true but OnMessageReceivedOnTargetThread() is |
| + // never called. By default this does nothing. |
| + virtual void OnStaleMessageReceived(const IPC::Message& msg) {} |
|
jam
2013/11/08 19:51:59
can you also add a Send() method, i.e. see https:/
kinuko
2013/11/15 14:40:36
Done.
|
| + |
| + protected: |
| + CrossThreadMessageFilter(); |
| + virtual ~CrossThreadMessageFilter(); |
| + |
| + private: |
| + class Internal; |
| + friend class ChildThread; |
| + friend class RenderThreadImpl; |
| + friend class WorkerThread; |
| + |
| + friend class base::RefCountedThreadSafe<CrossThreadMessageFilter>; |
| + |
| + IPC::ChannelProxy::MessageFilter* GetFilter(); |
| + |
| + // This implements IPC::ChannelProxy::MessageFilter to hide the actual |
| + // filter methods from child classes. |
| + Internal* internal_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(CrossThreadMessageFilter); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_CHILD_CROSS_THREAD_MESSAGE_FILTER_H_ |