| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CONTENT_COMMON_QUOTA_DISPATCHER_H_ | |
| 6 #define CONTENT_COMMON_QUOTA_DISPATCHER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <set> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/id_map.h" | |
| 13 #include "ipc/ipc_listener.h" | |
| 14 #include "webkit/common/quota/quota_types.h" | |
| 15 | |
| 16 class GURL; | |
| 17 | |
| 18 namespace IPC { | |
| 19 class Message; | |
| 20 } | |
| 21 | |
| 22 namespace WebKit { | |
| 23 class WebStorageQuotaCallbacks; | |
| 24 } | |
| 25 | |
| 26 namespace content { | |
| 27 | |
| 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 { | |
| 32 public: | |
| 33 class Callback { | |
| 34 public: | |
| 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; | |
| 39 }; | |
| 40 | |
| 41 QuotaDispatcher(); | |
| 42 virtual ~QuotaDispatcher(); | |
| 43 | |
| 44 // IPC::Listener implementation. | |
| 45 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | |
| 46 | |
| 47 void QueryStorageUsageAndQuota(const GURL& gurl, | |
| 48 quota::StorageType type, | |
| 49 Callback* callback); | |
| 50 void RequestStorageQuota(int render_view_id, | |
| 51 const GURL& gurl, | |
| 52 quota::StorageType type, | |
| 53 int64 requested_size, | |
| 54 Callback* callback); | |
| 55 | |
| 56 // Creates a new Callback instance for WebStorageQuotaCallbacks. | |
| 57 static Callback* CreateWebStorageQuotaCallbacksWrapper( | |
| 58 WebKit::WebStorageQuotaCallbacks* callbacks); | |
| 59 | |
| 60 private: | |
| 61 // Message handlers. | |
| 62 void DidQueryStorageUsageAndQuota(int request_id, | |
| 63 int64 current_usage, | |
| 64 int64 current_quota); | |
| 65 void DidGrantStorageQuota(int request_id, | |
| 66 int64 granted_quota); | |
| 67 void DidFail(int request_id, quota::QuotaStatusCode error); | |
| 68 | |
| 69 IDMap<Callback, IDMapOwnPointer> pending_quota_callbacks_; | |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(QuotaDispatcher); | |
| 72 }; | |
| 73 | |
| 74 } // namespace content | |
| 75 | |
| 76 #endif // CONTENT_COMMON_QUOTA_DISPATCHER_H_ | |
| OLD | NEW |