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