1 // Copyright (c) 2011 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_COMMON_QUOTA_DISPATCHER_H_
6 #define CONTENT_COMMON_QUOTA_DISPATCHER_H_
11 #include "base/basictypes.h"
12 #include "base/id_map.h"
13 #include "ipc/ipc_listener.h"
14 #include "webkit/quota/quota_types.h"
23 class WebStorageQuotaCallbacks
;
28 // Dispatches and sends quota related messages sent to/from a child
29 // process from/to the main browser process. There is one instance
30 // per child process. Messages are dispatched on the main child thread.
31 class QuotaDispatcher
: public IPC::Listener
{
35 virtual ~Callback() {}
36 virtual void DidQueryStorageUsageAndQuota(int64 usage
, int64 quota
) = 0;
37 virtual void DidGrantStorageQuota(int64 granted_quota
) = 0;
38 virtual void DidFail(quota::QuotaStatusCode status
) = 0;
42 virtual ~QuotaDispatcher();
44 // IPC::Listener implementation.
45 virtual bool OnMessageReceived(const IPC::Message
& msg
) OVERRIDE
;
47 void QueryStorageUsageAndQuota(const GURL
& gurl
,
48 quota::StorageType type
,
50 void RequestStorageQuota(int render_view_id
,
52 quota::StorageType type
,
56 // Creates a new Callback instance for WebStorageQuotaCallbacks.
57 static Callback
* CreateWebStorageQuotaCallbacksWrapper(
58 WebKit::WebStorageQuotaCallbacks
* callbacks
);
62 void DidQueryStorageUsageAndQuota(int request_id
,
65 void DidGrantStorageQuota(int request_id
,
67 void DidFail(int request_id
, quota::QuotaStatusCode error
);
69 IDMap
<Callback
, IDMapOwnPointer
> pending_quota_callbacks_
;
71 DISALLOW_COPY_AND_ASSIGN(QuotaDispatcher
);
74 } // namespace content
76 #endif // CONTENT_COMMON_QUOTA_DISPATCHER_H_