| 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 WEBKIT_APPCACHE_APPCACHE_QUOTA_CLIENT_H_ | 5 #ifndef WEBKIT_APPCACHE_APPCACHE_QUOTA_CLIENT_H_ |
| 6 #define WEBKIT_APPCACHE_APPCACHE_QUOTA_CLIENT_H_ | 6 #define WEBKIT_APPCACHE_APPCACHE_QUOTA_CLIENT_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // been destroyed. | 31 // been destroyed. |
| 32 class AppCacheQuotaClient : public quota::QuotaClient { | 32 class AppCacheQuotaClient : public quota::QuotaClient { |
| 33 public: | 33 public: |
| 34 virtual ~AppCacheQuotaClient(); | 34 virtual ~AppCacheQuotaClient(); |
| 35 | 35 |
| 36 // QuotaClient method overrides | 36 // QuotaClient method overrides |
| 37 virtual ID id() const OVERRIDE; | 37 virtual ID id() const OVERRIDE; |
| 38 virtual void OnQuotaManagerDestroyed(); | 38 virtual void OnQuotaManagerDestroyed(); |
| 39 virtual void GetOriginUsage(const GURL& origin, | 39 virtual void GetOriginUsage(const GURL& origin, |
| 40 quota::StorageType type, | 40 quota::StorageType type, |
| 41 GetUsageCallback* callback) OVERRIDE; | 41 GetUsageCallback callback) OVERRIDE; |
| 42 virtual void GetOriginsForType(quota::StorageType type, | 42 virtual void GetOriginsForType(quota::StorageType type, |
| 43 GetOriginsCallback* callback) OVERRIDE; | 43 GetOriginsCallback callback) OVERRIDE; |
| 44 virtual void GetOriginsForHost(quota::StorageType type, | 44 virtual void GetOriginsForHost(quota::StorageType type, |
| 45 const std::string& host, | 45 const std::string& host, |
| 46 GetOriginsCallback* callback) OVERRIDE; | 46 GetOriginsCallback callback) OVERRIDE; |
| 47 virtual void DeleteOriginData(const GURL& origin, | 47 virtual void DeleteOriginData(const GURL& origin, |
| 48 quota::StorageType type, | 48 quota::StorageType type, |
| 49 DeletionCallback* callback) OVERRIDE; | 49 DeletionCallback callback) OVERRIDE; |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 friend class AppCacheService; // for NotifyAppCacheIsDestroyed | 52 friend class AppCacheService; // for NotifyAppCacheIsDestroyed |
| 53 friend class AppCacheStorageImpl; // for NotifyAppCacheIsReady | 53 friend class AppCacheStorageImpl; // for NotifyAppCacheIsReady |
| 54 friend class AppCacheQuotaClientTest; | 54 friend class AppCacheQuotaClientTest; |
| 55 | 55 |
| 56 struct UsageRequest { | 56 struct UsageRequest { |
| 57 GURL origin; | 57 GURL origin; |
| 58 quota::StorageType type; | 58 quota::StorageType type; |
| 59 GetUsageCallback* callback; | 59 GetUsageCallback callback; |
| 60 |
| 61 UsageRequest(); |
| 62 ~UsageRequest(); |
| 60 }; | 63 }; |
| 61 struct OriginsRequest { | 64 struct OriginsRequest { |
| 62 quota::StorageType type; | 65 quota::StorageType type; |
| 63 std::string opt_host; | 66 std::string opt_host; |
| 64 GetOriginsCallback* callback; | 67 GetOriginsCallback callback; |
| 68 |
| 69 OriginsRequest(); |
| 70 ~OriginsRequest(); |
| 65 }; | 71 }; |
| 66 struct DeleteRequest { | 72 struct DeleteRequest { |
| 67 GURL origin; | 73 GURL origin; |
| 68 quota::StorageType type; | 74 quota::StorageType type; |
| 69 DeletionCallback* callback; | 75 DeletionCallback callback; |
| 76 |
| 77 DeleteRequest(); |
| 78 ~DeleteRequest(); |
| 70 }; | 79 }; |
| 71 typedef std::deque<UsageRequest> UsageRequestQueue; | 80 typedef std::deque<UsageRequest> UsageRequestQueue; |
| 72 typedef std::deque<OriginsRequest> OriginsRequestQueue; | 81 typedef std::deque<OriginsRequest> OriginsRequestQueue; |
| 73 typedef std::deque<DeleteRequest> DeleteRequestQueue; | 82 typedef std::deque<DeleteRequest> DeleteRequestQueue; |
| 74 | 83 |
| 75 explicit AppCacheQuotaClient(AppCacheService* service); | 84 explicit AppCacheQuotaClient(AppCacheService* service); |
| 76 | 85 |
| 77 void DidDeleteAppCachesForOrigin(int rv); | 86 void DidDeleteAppCachesForOrigin(int rv); |
| 78 void GetOriginsHelper(quota::StorageType type, | 87 void GetOriginsHelper(quota::StorageType type, |
| 79 const std::string& opt_host, | 88 const std::string& opt_host, |
| 80 GetOriginsCallback* callback_ptr); | 89 GetOriginsCallback callback_ptr); |
| 81 void ProcessPendingRequests(); | 90 void ProcessPendingRequests(); |
| 82 void AbortPendingRequests(); | 91 void AbortPendingRequests(); |
| 83 void DeletePendingRequests(); | 92 void DeletePendingRequests(); |
| 84 const AppCacheStorage::UsageMap* GetUsageMap(); | 93 const AppCacheStorage::UsageMap* GetUsageMap(); |
| 85 | 94 |
| 86 // For use by appcache internals during initialization and shutdown. | 95 // For use by appcache internals during initialization and shutdown. |
| 87 void NotifyAppCacheReady(); | 96 void NotifyAppCacheReady(); |
| 88 void NotifyAppCacheDestroyed(); | 97 void NotifyAppCacheDestroyed(); |
| 89 | 98 |
| 90 // Prior to appcache service being ready, we have to queue | 99 // Prior to appcache service being ready, we have to queue |
| 91 // up reqeusts and defer acting on them until we're ready. | 100 // up reqeusts and defer acting on them until we're ready. |
| 92 UsageRequestQueue pending_usage_requests_; | 101 UsageRequestQueue pending_usage_requests_; |
| 93 OriginsRequestQueue pending_origins_requests_; | 102 OriginsRequestQueue pending_origins_requests_; |
| 94 DeleteRequestQueue pending_delete_requests_; | 103 DeleteRequestQueue pending_delete_requests_; |
| 95 | 104 |
| 96 // And once it's ready, we can only handle one delete request at a time, | 105 // And once it's ready, we can only handle one delete request at a time, |
| 97 // so we queue up additional requests while one is in already in progress. | 106 // so we queue up additional requests while one is in already in progress. |
| 98 scoped_ptr<DeletionCallback> current_delete_request_callback_; | 107 DeletionCallback current_delete_request_callback_; |
| 99 scoped_refptr<net::CancelableCompletionCallback<AppCacheQuotaClient> > | 108 scoped_refptr<net::CancelableCompletionCallback<AppCacheQuotaClient> > |
| 100 service_delete_callback_; | 109 service_delete_callback_; |
| 101 | 110 |
| 102 AppCacheService* service_; | 111 AppCacheService* service_; |
| 103 bool appcache_is_ready_; | 112 bool appcache_is_ready_; |
| 104 bool quota_manager_is_destroyed_; | 113 bool quota_manager_is_destroyed_; |
| 105 | 114 |
| 106 DISALLOW_COPY_AND_ASSIGN(AppCacheQuotaClient); | 115 DISALLOW_COPY_AND_ASSIGN(AppCacheQuotaClient); |
| 107 }; | 116 }; |
| 108 | 117 |
| 109 } // namespace appcache | 118 } // namespace appcache |
| 110 | 119 |
| 111 #endif // WEBKIT_APPCACHE_APPCACHE_QUOTA_CLIENT_H_ | 120 #endif // WEBKIT_APPCACHE_APPCACHE_QUOTA_CLIENT_H_ |
| OLD | NEW |