Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: webkit/appcache/appcache_quota_client.h

Issue 8230012: Cleanup AppCacheQuotaClient using new Callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix infinite recursion Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 14 matching lines...) Expand all
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
31 // itself when both the quota manager and the appcache service have 31 // itself when both the quota manager and the appcache service have
32 // been destroyed. 32 // been destroyed.
33 class AppCacheQuotaClient : public quota::QuotaClient { 33 class AppCacheQuotaClient : public quota::QuotaClient {
34 public: 34 public:
35 typedef std::deque<base::Closure> RequestQueue;
36
35 virtual ~AppCacheQuotaClient(); 37 virtual ~AppCacheQuotaClient();
36 38
37 // QuotaClient method overrides 39 // QuotaClient method overrides
38 virtual ID id() const OVERRIDE; 40 virtual ID id() const OVERRIDE;
39 virtual void OnQuotaManagerDestroyed(); 41 virtual void OnQuotaManagerDestroyed();
40 virtual void GetOriginUsage(const GURL& origin, 42 virtual void GetOriginUsage(const GURL& origin,
41 quota::StorageType type, 43 quota::StorageType type,
42 const GetUsageCallback& callback) OVERRIDE; 44 const GetUsageCallback& callback) OVERRIDE;
43 virtual void GetOriginsForType(quota::StorageType type, 45 virtual void GetOriginsForType(quota::StorageType type,
44 const GetOriginsCallback& callback) OVERRIDE; 46 const GetOriginsCallback& callback) OVERRIDE;
45 virtual void GetOriginsForHost(quota::StorageType type, 47 virtual void GetOriginsForHost(quota::StorageType type,
46 const std::string& host, 48 const std::string& host,
47 const GetOriginsCallback& callback) OVERRIDE; 49 const GetOriginsCallback& callback) OVERRIDE;
48 virtual void DeleteOriginData(const GURL& origin, 50 virtual void DeleteOriginData(const GURL& origin,
49 quota::StorageType type, 51 quota::StorageType type,
50 const DeletionCallback& callback) OVERRIDE; 52 const DeletionCallback& callback) OVERRIDE;
51 53
52 private: 54 private:
53 friend class AppCacheService; // for NotifyAppCacheIsDestroyed 55 friend class AppCacheService; // for NotifyAppCacheIsDestroyed
54 friend class AppCacheStorageImpl; // for NotifyAppCacheIsReady 56 friend class AppCacheStorageImpl; // for NotifyAppCacheIsReady
55 friend class AppCacheQuotaClientTest; 57 friend class AppCacheQuotaClientTest;
56 58
57 struct UsageRequest {
58 GURL origin;
59 quota::StorageType type;
60 GetUsageCallback callback;
61
62 UsageRequest();
63 ~UsageRequest();
64 };
65 struct OriginsRequest {
66 quota::StorageType type;
67 std::string opt_host;
68 GetOriginsCallback callback;
69
70 OriginsRequest();
71 ~OriginsRequest();
72 };
73 struct DeleteRequest {
74 GURL origin;
75 quota::StorageType type;
76 DeletionCallback callback;
77
78 DeleteRequest();
79 ~DeleteRequest();
80 };
81 typedef std::deque<UsageRequest> UsageRequestQueue;
82 typedef std::deque<OriginsRequest> OriginsRequestQueue;
83 typedef std::deque<DeleteRequest> DeleteRequestQueue;
84
85 APPCACHE_EXPORT explicit AppCacheQuotaClient(AppCacheService* service); 59 APPCACHE_EXPORT explicit AppCacheQuotaClient(AppCacheService* service);
86 60
87 void DidDeleteAppCachesForOrigin(int rv); 61 void DidDeleteAppCachesForOrigin(int rv);
88 void GetOriginsHelper(quota::StorageType type, 62 void GetOriginsHelper(quota::StorageType type,
89 const std::string& opt_host, 63 const std::string& opt_host,
90 const GetOriginsCallback& callback); 64 const GetOriginsCallback& callback);
91 void ProcessPendingRequests(); 65 void ProcessPendingRequests();
92 void AbortPendingRequests();
93 void DeletePendingRequests(); 66 void DeletePendingRequests();
94 const AppCacheStorage::UsageMap* GetUsageMap(); 67 const AppCacheStorage::UsageMap* GetUsageMap();
95 68
96 // For use by appcache internals during initialization and shutdown. 69 // For use by appcache internals during initialization and shutdown.
97 APPCACHE_EXPORT void NotifyAppCacheReady(); 70 APPCACHE_EXPORT void NotifyAppCacheReady();
98 APPCACHE_EXPORT void NotifyAppCacheDestroyed(); 71 APPCACHE_EXPORT void NotifyAppCacheDestroyed();
99 72
100 // Prior to appcache service being ready, we have to queue 73 // Prior to appcache service being ready, we have to queue
101 // up reqeusts and defer acting on them until we're ready. 74 // up reqeusts and defer acting on them until we're ready.
102 UsageRequestQueue pending_usage_requests_; 75 RequestQueue pending_batch_requests_;
103 OriginsRequestQueue pending_origins_requests_; 76 RequestQueue pending_serial_requests_;
104 DeleteRequestQueue pending_delete_requests_;
105 77
106 // And once it's ready, we can only handle one delete request at a time, 78 // And once it's ready, we can only handle one delete request at a time,
107 // so we queue up additional requests while one is in already in progress. 79 // so we queue up additional requests while one is in already in progress.
108 DeletionCallback current_delete_request_callback_; 80 DeletionCallback current_delete_request_callback_;
109 scoped_refptr<net::CancelableOldCompletionCallback<AppCacheQuotaClient> > 81 scoped_refptr<net::CancelableOldCompletionCallback<AppCacheQuotaClient> >
110 service_delete_callback_; 82 service_delete_callback_;
111 83
112 AppCacheService* service_; 84 AppCacheService* service_;
113 bool appcache_is_ready_; 85 bool appcache_is_ready_;
114 bool quota_manager_is_destroyed_; 86 bool quota_manager_is_destroyed_;
115 87
116 DISALLOW_COPY_AND_ASSIGN(AppCacheQuotaClient); 88 DISALLOW_COPY_AND_ASSIGN(AppCacheQuotaClient);
117 }; 89 };
118 90
119 } // namespace appcache 91 } // namespace appcache
120 92
121 #endif // WEBKIT_APPCACHE_APPCACHE_QUOTA_CLIENT_H_ 93 #endif // WEBKIT_APPCACHE_APPCACHE_QUOTA_CLIENT_H_
OLDNEW
« no previous file with comments | « no previous file | webkit/appcache/appcache_quota_client.cc » ('j') | webkit/appcache/appcache_quota_client.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698