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

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

Issue 7031065: AppCache + Quota integration (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef WEBKIT_APPCACHE_APPCACHE_QUOTA_CLIENT_H_
6 #define WEBKIT_APPCACHE_APPCACHE_QUOTA_CLIENT_H_
7
8 #include <deque>
9 #include <map>
10 #include <string>
11
12 #include "base/gtest_prod_util.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "net/base/completion_callback.h"
16 #include "webkit/appcache/appcache_storage.h"
17 #include "webkit/quota/quota_client.h"
18 #include "webkit/quota/quota_task.h"
19 #include "webkit/quota/quota_types.h"
20
21 namespace appcache {
22
23 class AppCacheService;
24 class AppCacheStorageImpl;
25 class AppCacheQuotaClientTest;
26
27 // A QuotaClient implementation to integrate the appcache service
28 // with the quota management system. The QuotaClient interface is
29 // used on the IO thread by the quota manager. This class deletes
30 // itself when both the quota manager and the appcache service have
31 // been destroyed.
32 class AppCacheQuotaClient : public quota::QuotaClient {
33 public:
34 virtual ~AppCacheQuotaClient();
35
36 // QuotaClient method overrides
37 virtual ID id() const OVERRIDE;
38 virtual void OnQuotaManagerDestroyed();
39 virtual void GetOriginUsage(const GURL& origin,
40 quota::StorageType type,
41 GetUsageCallback* callback) OVERRIDE;
42 virtual void GetOriginsForType(quota::StorageType type,
43 GetOriginsCallback* callback) OVERRIDE;
44 virtual void GetOriginsForHost(quota::StorageType type,
45 const std::string& host,
46 GetOriginsCallback* callback) OVERRIDE;
47 virtual void DeleteOriginData(const GURL& origin,
48 quota::StorageType type,
49 DeletionCallback* callback) OVERRIDE;
50
51 private:
52 friend AppCacheService; // for NotifyAppCacheIsDestroyed
53 friend AppCacheStorageImpl; // for NotifyAppCacheIsReady
54 friend AppCacheQuotaClientTest;
55
56 struct UsageRequest {
57 GURL origin;
58 quota::StorageType type;
59 GetUsageCallback* callback;
60 };
61 struct OriginsRequest {
62 quota::StorageType type;
63 std::string opt_host;
64 GetOriginsCallback* callback;
65 };
66 struct DeleteRequest {
67 GURL origin;
68 quota::StorageType type;
69 DeletionCallback* callback;
70 };
71 typedef std::deque<UsageRequest> UsageRequestQueue;
72 typedef std::deque<OriginsRequest> OriginsRequestQueue;
73 typedef std::deque<DeleteRequest> DeleteRequestQueue;
74
75 explicit AppCacheQuotaClient(AppCacheService* service);
76
77 void DidDeleteAppCachesForOrigin(int rv);
78 void GetOriginsHelper(quota::StorageType type,
79 const std::string& opt_host,
80 GetOriginsCallback* callback_ptr);
81 void ProcessPendingRequests();
82 void AbortPendingRequests();
83 void DeletePendingRequests();
84 const AppCacheStorage::UsageMap* GetUsageMap();
85
86 // For use by appcache internals during initialization and shutdown.
87 void NotifyAppCacheReady();
88 void NotifyAppCacheDestroyed();
89
90 static void AbortUsageRequest(const UsageRequest& request);
91 static void AbortOriginsRequest(const OriginsRequest& request);
92 static void AbortDeleteRequest(const DeleteRequest& request);
93
94 // Prior to appcache service being ready, we have to queue
95 // up reqeusts and defer acting on them until we're ready.
96 UsageRequestQueue pending_usage_requests_;
97 OriginsRequestQueue pending_origins_requests_;
98 DeleteRequestQueue pending_delete_requests_;
99
100 // And once it's ready, we can only handle one delete request at a time,
101 // so we queue up additional requests while one is in already in progress.
102 scoped_ptr<DeletionCallback> current_delete_request_callback_;
103 scoped_refptr<net::CancelableCompletionCallback<AppCacheQuotaClient> >
104 service_delete_callback_;
105
106 AppCacheService* service_;
107 bool appcache_is_ready_;
108 bool quota_manager_is_destroyed_;
109
110 DISALLOW_COPY_AND_ASSIGN(AppCacheQuotaClient);
111 };
112
113 } // namespace appcache
114
115 #endif // WEBKIT_APPCACHE_APPCACHE_QUOTA_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698