OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_COMMON_QUOTA_DISPATCHER_H_ | 5 #ifndef CONTENT_COMMON_QUOTA_DISPATCHER_H_ |
6 #define CONTENT_COMMON_QUOTA_DISPATCHER_H_ | 6 #define CONTENT_COMMON_QUOTA_DISPATCHER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/id_map.h" | 12 #include "base/id_map.h" |
13 #include "ipc/ipc_channel.h" | 13 #include "ipc/ipc_channel.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaError.
h" | 14 #include "webkit/quota/quota_types.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaType.h
" | |
16 | 15 |
17 class GURL; | 16 class GURL; |
18 | 17 |
19 namespace IPC { | 18 namespace IPC { |
20 class Message; | 19 class Message; |
21 } | 20 } |
22 | 21 |
23 namespace WebKit { | 22 namespace WebKit { |
24 class WebStorageQuotaCallbacks; | 23 class WebStorageQuotaCallbacks; |
25 } | 24 } |
26 | 25 |
27 // Dispatches and sends quota related messages sent to/from a child | 26 // Dispatches and sends quota related messages sent to/from a child |
28 // process from/to the main browser process. There is one instance | 27 // process from/to the main browser process. There is one instance |
29 // per child process. Messages are dispatched on the main child thread. | 28 // per child process. Messages are dispatched on the main child thread. |
30 class QuotaDispatcher : public IPC::Channel::Listener { | 29 class QuotaDispatcher : public IPC::Channel::Listener { |
31 public: | 30 public: |
| 31 class Callback { |
| 32 public: |
| 33 virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) = 0; |
| 34 virtual void DidGrantStorageQuota(int64 granted_quota) = 0; |
| 35 virtual void DidFail(quota::QuotaStatusCode status) = 0; |
| 36 }; |
| 37 |
32 QuotaDispatcher(); | 38 QuotaDispatcher(); |
33 virtual ~QuotaDispatcher(); | 39 virtual ~QuotaDispatcher(); |
34 | 40 |
35 // IPC::Channel::Listener implementation. | 41 // IPC::Channel::Listener implementation. |
36 virtual bool OnMessageReceived(const IPC::Message& msg); | 42 virtual bool OnMessageReceived(const IPC::Message& msg); |
37 | 43 |
38 void QueryStorageUsageAndQuota(const GURL& gurl, | 44 void QueryStorageUsageAndQuota(const GURL& gurl, |
39 WebKit::WebStorageQuotaType type, | 45 quota::StorageType type, |
40 WebKit::WebStorageQuotaCallbacks* callbacks); | 46 Callback* callback); |
41 void RequestStorageQuota(int render_view_id, | 47 void RequestStorageQuota(int render_view_id, |
42 const GURL& gurl, | 48 const GURL& gurl, |
43 WebKit::WebStorageQuotaType type, | 49 quota::StorageType type, |
44 unsigned long long requested_size, | 50 int64 requested_size, |
45 WebKit::WebStorageQuotaCallbacks* callbacks); | 51 Callback* callback); |
| 52 |
| 53 // Creates a new Callback instance for WebStorageQuotaCallbacks. |
| 54 static Callback* CreateWebStorageQuotaCallbacksWrapper( |
| 55 WebKit::WebStorageQuotaCallbacks* callbacks); |
46 | 56 |
47 private: | 57 private: |
48 // Message handlers. | 58 // Message handlers. |
49 void DidQueryStorageUsageAndQuota(int request_id, | 59 void DidQueryStorageUsageAndQuota(int request_id, |
50 int64 current_usage, | 60 int64 current_usage, |
51 int64 current_quota); | 61 int64 current_quota); |
52 void DidGrantStorageQuota(int request_id, | 62 void DidGrantStorageQuota(int request_id, |
53 int64 granted_quota); | 63 int64 granted_quota); |
54 void DidFail(int request_id, | 64 void DidFail(int request_id, quota::QuotaStatusCode error); |
55 WebKit::WebStorageQuotaError error); | |
56 | 65 |
57 IDMap<WebKit::WebStorageQuotaCallbacks> pending_quota_callbacks_; | 66 IDMap<Callback, IDMapOwnPointer> pending_quota_callbacks_; |
58 | 67 |
59 DISALLOW_COPY_AND_ASSIGN(QuotaDispatcher); | 68 DISALLOW_COPY_AND_ASSIGN(QuotaDispatcher); |
60 }; | 69 }; |
61 | 70 |
62 #endif // CONTENT_COMMON_QUOTA_DISPATCHER_H_ | 71 #endif // CONTENT_COMMON_QUOTA_DISPATCHER_H_ |
OLD | NEW |