OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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_QUOTA_MESSAGE_FILTER_H_ |
| 6 #define CONTENT_CHILD_QUOTA_MESSAGE_FILTER_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/synchronization/lock.h" |
| 11 #include "ipc/ipc_channel_proxy.h" |
| 12 |
| 13 namespace base { |
| 14 class MessageLoopProxy; |
| 15 } |
| 16 |
| 17 namespace content { |
| 18 |
| 19 class ThreadSafeSender; |
| 20 |
| 21 class QuotaMessageFilter : public IPC::ChannelProxy::MessageFilter { |
| 22 public: |
| 23 explicit QuotaMessageFilter(ThreadSafeSender* thread_safe_sender); |
| 24 |
| 25 // IPC::Listener implementation. |
| 26 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| 27 |
| 28 // Registers { request_id, thread_id } map to the message filter. |
| 29 // This method can be called on any thread. |
| 30 void RegisterRequestID(int request_id, int thread_id); |
| 31 |
| 32 protected: |
| 33 virtual ~QuotaMessageFilter(); |
| 34 |
| 35 private: |
| 36 typedef std::map<int, int> RequestIdToThreadId; |
| 37 |
| 38 void DispatchMessage(const IPC::Message& msg); |
| 39 |
| 40 scoped_refptr<base::MessageLoopProxy> main_thread_loop_proxy_; |
| 41 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 42 |
| 43 base::Lock request_id_map_lock_; |
| 44 RequestIdToThreadId request_id_map_; |
| 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(QuotaMessageFilter); |
| 47 }; |
| 48 |
| 49 } // namespace content |
| 50 |
| 51 #endif // CONTENT_CHILD_QUOTA_MESSAGE_FILTER_H_ |
OLD | NEW |