| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BROWSER_APPCACHE_APPCACHE_QUOTA_CLIENT_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_QUOTA_CLIENT_H_ |
| 6 #define WEBKIT_BROWSER_APPCACHE_APPCACHE_QUOTA_CLIENT_H_ | 6 #define CONTENT_BROWSER_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 "content/browser/appcache/appcache_storage.h" |
| 16 #include "content/common/content_export.h" |
| 15 #include "net/base/completion_callback.h" | 17 #include "net/base/completion_callback.h" |
| 16 #include "webkit/browser/appcache/appcache_storage.h" | |
| 17 #include "webkit/browser/quota/quota_client.h" | 18 #include "webkit/browser/quota/quota_client.h" |
| 18 #include "webkit/browser/quota/quota_task.h" | 19 #include "webkit/browser/quota/quota_task.h" |
| 19 #include "webkit/browser/webkit_storage_browser_export.h" | |
| 20 #include "webkit/common/quota/quota_types.h" | 20 #include "webkit/common/quota/quota_types.h" |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 class AppCacheQuotaClientTest; | 23 class AppCacheQuotaClientTest; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace appcache { | 26 namespace content { |
| 27 | 27 |
| 28 class AppCacheServiceImpl; | 28 class AppCacheServiceImpl; |
| 29 class AppCacheStorageImpl; | 29 class AppCacheStorageImpl; |
| 30 class AppCacheQuotaClientTest; | 30 class AppCacheQuotaClientTest; |
| 31 | 31 |
| 32 // A QuotaClient implementation to integrate the appcache service | 32 // A QuotaClient implementation to integrate the appcache service |
| 33 // with the quota management system. The QuotaClient interface is | 33 // with the quota management system. The QuotaClient interface is |
| 34 // used on the IO thread by the quota manager. This class deletes | 34 // used on the IO thread by the quota manager. This class deletes |
| 35 // itself when both the quota manager and the appcache service have | 35 // itself when both the quota manager and the appcache service have |
| 36 // been destroyed. | 36 // been destroyed. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 54 virtual void DeleteOriginData(const GURL& origin, | 54 virtual void DeleteOriginData(const GURL& origin, |
| 55 quota::StorageType type, | 55 quota::StorageType type, |
| 56 const DeletionCallback& callback) OVERRIDE; | 56 const DeletionCallback& callback) OVERRIDE; |
| 57 virtual bool DoesSupport(quota::StorageType type) const OVERRIDE; | 57 virtual bool DoesSupport(quota::StorageType type) const OVERRIDE; |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 friend class content::AppCacheQuotaClientTest; | 60 friend class content::AppCacheQuotaClientTest; |
| 61 friend class AppCacheServiceImpl; // for NotifyAppCacheIsDestroyed | 61 friend class AppCacheServiceImpl; // for NotifyAppCacheIsDestroyed |
| 62 friend class AppCacheStorageImpl; // for NotifyAppCacheIsReady | 62 friend class AppCacheStorageImpl; // for NotifyAppCacheIsReady |
| 63 | 63 |
| 64 WEBKIT_STORAGE_BROWSER_EXPORT | 64 CONTENT_EXPORT |
| 65 explicit AppCacheQuotaClient(AppCacheServiceImpl* service); | 65 explicit AppCacheQuotaClient(AppCacheServiceImpl* service); |
| 66 | 66 |
| 67 void DidDeleteAppCachesForOrigin(int rv); | 67 void DidDeleteAppCachesForOrigin(int rv); |
| 68 void GetOriginsHelper(quota::StorageType type, | 68 void GetOriginsHelper(quota::StorageType type, |
| 69 const std::string& opt_host, | 69 const std::string& opt_host, |
| 70 const GetOriginsCallback& callback); | 70 const GetOriginsCallback& callback); |
| 71 void ProcessPendingRequests(); | 71 void ProcessPendingRequests(); |
| 72 void DeletePendingRequests(); | 72 void DeletePendingRequests(); |
| 73 const AppCacheStorage::UsageMap* GetUsageMap(); | 73 const AppCacheStorage::UsageMap* GetUsageMap(); |
| 74 net::CancelableCompletionCallback* GetServiceDeleteCallback(); | 74 net::CancelableCompletionCallback* GetServiceDeleteCallback(); |
| 75 | 75 |
| 76 // For use by appcache internals during initialization and shutdown. | 76 // For use by appcache internals during initialization and shutdown. |
| 77 WEBKIT_STORAGE_BROWSER_EXPORT void NotifyAppCacheReady(); | 77 CONTENT_EXPORT void NotifyAppCacheReady(); |
| 78 WEBKIT_STORAGE_BROWSER_EXPORT void NotifyAppCacheDestroyed(); | 78 CONTENT_EXPORT void NotifyAppCacheDestroyed(); |
| 79 | 79 |
| 80 // Prior to appcache service being ready, we have to queue | 80 // Prior to appcache service being ready, we have to queue |
| 81 // up reqeusts and defer acting on them until we're ready. | 81 // up reqeusts and defer acting on them until we're ready. |
| 82 RequestQueue pending_batch_requests_; | 82 RequestQueue pending_batch_requests_; |
| 83 RequestQueue pending_serial_requests_; | 83 RequestQueue pending_serial_requests_; |
| 84 | 84 |
| 85 // And once it's ready, we can only handle one delete request at a time, | 85 // And once it's ready, we can only handle one delete request at a time, |
| 86 // so we queue up additional requests while one is in already in progress. | 86 // so we queue up additional requests while one is in already in progress. |
| 87 DeletionCallback current_delete_request_callback_; | 87 DeletionCallback current_delete_request_callback_; |
| 88 scoped_ptr<net::CancelableCompletionCallback> service_delete_callback_; | 88 scoped_ptr<net::CancelableCompletionCallback> service_delete_callback_; |
| 89 | 89 |
| 90 AppCacheServiceImpl* service_; | 90 AppCacheServiceImpl* service_; |
| 91 bool appcache_is_ready_; | 91 bool appcache_is_ready_; |
| 92 bool quota_manager_is_destroyed_; | 92 bool quota_manager_is_destroyed_; |
| 93 | 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(AppCacheQuotaClient); | 94 DISALLOW_COPY_AND_ASSIGN(AppCacheQuotaClient); |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 } // namespace appcache | 97 } // namespace content |
| 98 | 98 |
| 99 #endif // WEBKIT_BROWSER_APPCACHE_APPCACHE_QUOTA_CLIENT_H_ | 99 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_QUOTA_CLIENT_H_ |
| OLD | NEW |