IndexedDBFactory now ForceCloses databases.
[chromium-blink-merge.git] / content / child / quota_message_filter.h
blobeabff1bf8ca727a74c5d682714fe60436018f1ae
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.
5 #ifndef CONTENT_CHILD_QUOTA_MESSAGE_FILTER_H_
6 #define CONTENT_CHILD_QUOTA_MESSAGE_FILTER_H_
8 #include <map>
10 #include "base/synchronization/lock.h"
11 #include "content/child/child_message_filter.h"
13 namespace base {
14 class MessageLoopProxy;
17 namespace content {
19 class ThreadSafeSender;
21 class QuotaMessageFilter : public ChildMessageFilter {
22 public:
23 explicit QuotaMessageFilter(ThreadSafeSender* thread_safe_sender);
25 // Generates a new request_id, registers { request_id, thread_id } map to
26 // the message filter and returns the request_id.
27 // This method can be called on any thread.
28 int GenerateRequestID(int thread_id);
30 // Clears all requests from the thread_id.
31 void ClearThreadRequests(int thread_id);
33 protected:
34 virtual ~QuotaMessageFilter();
36 private:
37 // ChildMessageFilter implementation:
38 virtual base::TaskRunner* OverrideTaskRunnerForMessage(
39 const IPC::Message& msg) OVERRIDE;
40 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
42 typedef std::map<int, int> RequestIdToThreadId;
44 scoped_refptr<base::MessageLoopProxy> main_thread_loop_proxy_;
45 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
47 base::Lock request_id_map_lock_;
48 RequestIdToThreadId request_id_map_;
49 int next_request_id_;
51 DISALLOW_COPY_AND_ASSIGN(QuotaMessageFilter);
54 } // namespace content
56 #endif // CONTENT_CHILD_QUOTA_MESSAGE_FILTER_H_