| 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> |
| 11 | 11 |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
| 16 #include "webkit/appcache/appcache_export.h" |
| 16 #include "webkit/appcache/appcache_storage.h" | 17 #include "webkit/appcache/appcache_storage.h" |
| 17 #include "webkit/quota/quota_client.h" | 18 #include "webkit/quota/quota_client.h" |
| 18 #include "webkit/quota/quota_task.h" | 19 #include "webkit/quota/quota_task.h" |
| 19 #include "webkit/quota/quota_types.h" | 20 #include "webkit/quota/quota_types.h" |
| 20 | 21 |
| 21 namespace appcache { | 22 namespace appcache { |
| 22 | 23 |
| 23 class AppCacheService; | 24 class AppCacheService; |
| 24 class AppCacheStorageImpl; | 25 class AppCacheStorageImpl; |
| 25 class AppCacheQuotaClientTest; | 26 class AppCacheQuotaClientTest; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 }; | 66 }; |
| 66 struct DeleteRequest { | 67 struct DeleteRequest { |
| 67 GURL origin; | 68 GURL origin; |
| 68 quota::StorageType type; | 69 quota::StorageType type; |
| 69 DeletionCallback* callback; | 70 DeletionCallback* callback; |
| 70 }; | 71 }; |
| 71 typedef std::deque<UsageRequest> UsageRequestQueue; | 72 typedef std::deque<UsageRequest> UsageRequestQueue; |
| 72 typedef std::deque<OriginsRequest> OriginsRequestQueue; | 73 typedef std::deque<OriginsRequest> OriginsRequestQueue; |
| 73 typedef std::deque<DeleteRequest> DeleteRequestQueue; | 74 typedef std::deque<DeleteRequest> DeleteRequestQueue; |
| 74 | 75 |
| 75 explicit AppCacheQuotaClient(AppCacheService* service); | 76 APPCACHE_EXPORT explicit AppCacheQuotaClient(AppCacheService* service); |
| 76 | 77 |
| 77 void DidDeleteAppCachesForOrigin(int rv); | 78 void DidDeleteAppCachesForOrigin(int rv); |
| 78 void GetOriginsHelper(quota::StorageType type, | 79 void GetOriginsHelper(quota::StorageType type, |
| 79 const std::string& opt_host, | 80 const std::string& opt_host, |
| 80 GetOriginsCallback* callback_ptr); | 81 GetOriginsCallback* callback_ptr); |
| 81 void ProcessPendingRequests(); | 82 void ProcessPendingRequests(); |
| 82 void AbortPendingRequests(); | 83 void AbortPendingRequests(); |
| 83 void DeletePendingRequests(); | 84 void DeletePendingRequests(); |
| 84 const AppCacheStorage::UsageMap* GetUsageMap(); | 85 const AppCacheStorage::UsageMap* GetUsageMap(); |
| 85 | 86 |
| 86 // For use by appcache internals during initialization and shutdown. | 87 // For use by appcache internals during initialization and shutdown. |
| 87 void NotifyAppCacheReady(); | 88 APPCACHE_EXPORT void NotifyAppCacheReady(); |
| 88 void NotifyAppCacheDestroyed(); | 89 APPCACHE_EXPORT void NotifyAppCacheDestroyed(); |
| 89 | 90 |
| 90 // Prior to appcache service being ready, we have to queue | 91 // Prior to appcache service being ready, we have to queue |
| 91 // up reqeusts and defer acting on them until we're ready. | 92 // up reqeusts and defer acting on them until we're ready. |
| 92 UsageRequestQueue pending_usage_requests_; | 93 UsageRequestQueue pending_usage_requests_; |
| 93 OriginsRequestQueue pending_origins_requests_; | 94 OriginsRequestQueue pending_origins_requests_; |
| 94 DeleteRequestQueue pending_delete_requests_; | 95 DeleteRequestQueue pending_delete_requests_; |
| 95 | 96 |
| 96 // And once it's ready, we can only handle one delete request at a time, | 97 // 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. | 98 // so we queue up additional requests while one is in already in progress. |
| 98 scoped_ptr<DeletionCallback> current_delete_request_callback_; | 99 scoped_ptr<DeletionCallback> current_delete_request_callback_; |
| 99 scoped_refptr<net::CancelableCompletionCallback<AppCacheQuotaClient> > | 100 scoped_refptr<net::CancelableCompletionCallback<AppCacheQuotaClient> > |
| 100 service_delete_callback_; | 101 service_delete_callback_; |
| 101 | 102 |
| 102 AppCacheService* service_; | 103 AppCacheService* service_; |
| 103 bool appcache_is_ready_; | 104 bool appcache_is_ready_; |
| 104 bool quota_manager_is_destroyed_; | 105 bool quota_manager_is_destroyed_; |
| 105 | 106 |
| 106 DISALLOW_COPY_AND_ASSIGN(AppCacheQuotaClient); | 107 DISALLOW_COPY_AND_ASSIGN(AppCacheQuotaClient); |
| 107 }; | 108 }; |
| 108 | 109 |
| 109 } // namespace appcache | 110 } // namespace appcache |
| 110 | 111 |
| 111 #endif // WEBKIT_APPCACHE_APPCACHE_QUOTA_CLIENT_H_ | 112 #endif // WEBKIT_APPCACHE_APPCACHE_QUOTA_CLIENT_H_ |
| OLD | NEW |