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

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

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

Powered by Google App Engine
This is Rietveld 408576698