OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_CHILD_WEBSOCKET_MESSAGE_FILTER_H_ |
| 6 #define CONTENT_CHILD_WEBSOCKET_MESSAGE_FILTER_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "ipc/message_filter.h" |
| 12 |
| 13 namespace base { |
| 14 class SingleThreadTaskRunner; |
| 15 } |
| 16 |
| 17 namespace content { |
| 18 |
| 19 class WebSocketDispatcher; |
| 20 |
| 21 // Delegates IPC messages to a WebSocketDispatcher on the loading task queue |
| 22 // instead of the default task queue. |
| 23 class WebSocketMessageFilter : public IPC::MessageFilter { |
| 24 public: |
| 25 explicit WebSocketMessageFilter(WebSocketDispatcher* websocket_dispatcher); |
| 26 |
| 27 // IPC::MessageFilter implementation. |
| 28 bool OnMessageReceived(const IPC::Message& message) override; |
| 29 |
| 30 void SetLoadingTaskRunner( |
| 31 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner) { |
| 32 loading_task_runner_ = loading_task_runner; |
| 33 } |
| 34 |
| 35 private: |
| 36 ~WebSocketMessageFilter() override; |
| 37 void OnMessageReceivedOnMainThread(const IPC::Message& message); |
| 38 |
| 39 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner_; |
| 40 |
| 41 // This actual object is owned by a ChildThreadImpl and is derefed only on the |
| 42 // main thread. |
| 43 base::WeakPtr<WebSocketDispatcher> websocket_dispatcher_; |
| 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(WebSocketMessageFilter); |
| 46 }; |
| 47 |
| 48 } // namespace content |
| 49 |
| 50 #endif // CONTENT_CHILD_WEBSOCKET_MESSAGE_FILTER_H_ |
OLD | NEW |