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

Side by Side Diff: webkit/appcache/appcache_service.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
« no previous file with comments | « webkit/appcache/appcache_quota_client_unittest.cc ('k') | webkit/appcache/appcache_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_SERVICE_H_ 5 #ifndef WEBKIT_APPCACHE_APPCACHE_SERVICE_H_
6 #define WEBKIT_APPCACHE_APPCACHE_SERVICE_H_ 6 #define WEBKIT_APPCACHE_APPCACHE_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 17 matching lines...) Expand all
28 } 28 }
29 29
30 namespace quota { 30 namespace quota {
31 class QuotaManagerProxy; 31 class QuotaManagerProxy;
32 class SpecialStoragePolicy; 32 class SpecialStoragePolicy;
33 } 33 }
34 34
35 namespace appcache { 35 namespace appcache {
36 36
37 class AppCacheBackendImpl; 37 class AppCacheBackendImpl;
38 class AppCacheQuotaClient;
38 class AppCachePolicy; 39 class AppCachePolicy;
39 40
40 // Refcounted container to avoid copying the collection in callbacks. 41 // Refcounted container to avoid copying the collection in callbacks.
41 struct AppCacheInfoCollection 42 struct AppCacheInfoCollection
42 : public base::RefCountedThreadSafe<AppCacheInfoCollection> { 43 : public base::RefCountedThreadSafe<AppCacheInfoCollection> {
43 AppCacheInfoCollection(); 44 AppCacheInfoCollection();
44 virtual ~AppCacheInfoCollection(); 45 virtual ~AppCacheInfoCollection();
45 46
46 std::map<GURL, AppCacheInfoVector> infos_by_origin; 47 std::map<GURL, AppCacheInfoVector> infos_by_origin;
47 }; 48 };
(...skipping 29 matching lines...) Expand all
77 net::CompletionCallback* callback); 78 net::CompletionCallback* callback);
78 79
79 // Deletes the group identified by 'manifest_url', 'callback' is 80 // Deletes the group identified by 'manifest_url', 'callback' is
80 // invoked upon completion. Upon completion, the cache group and 81 // invoked upon completion. Upon completion, the cache group and
81 // any resources within the group are no longer loadable and all 82 // any resources within the group are no longer loadable and all
82 // subresource loads for pages associated with a deleted group 83 // subresource loads for pages associated with a deleted group
83 // will fail. This method always completes asynchronously. 84 // will fail. This method always completes asynchronously.
84 void DeleteAppCacheGroup(const GURL& manifest_url, 85 void DeleteAppCacheGroup(const GURL& manifest_url,
85 net::CompletionCallback* callback); 86 net::CompletionCallback* callback);
86 87
88 // Deletes all appcaches for the origin, 'callback' is invoked upon
89 // completion. This method always completes asynchronously.
90 // (virtual for unittesting)
91 virtual void DeleteAppCachesForOrigin(const GURL& origin,
92 net::CompletionCallback* callback);
93
87 // Context for use during cache updates, should only be accessed 94 // Context for use during cache updates, should only be accessed
88 // on the IO thread. We do NOT add a reference to the request context, 95 // on the IO thread. We do NOT add a reference to the request context,
89 // it is the callers responsibility to ensure that the pointer 96 // it is the callers responsibility to ensure that the pointer
90 // remains valid while set. 97 // remains valid while set.
91 net::URLRequestContext* request_context() const { return request_context_; } 98 net::URLRequestContext* request_context() const { return request_context_; }
92 void set_request_context(net::URLRequestContext* context) { 99 void set_request_context(net::URLRequestContext* context) {
93 request_context_ = context; 100 request_context_ = context;
94 } 101 }
95 102
96 // The appcache policy, may be null, in which case access is always allowed. 103 // The appcache policy, may be null, in which case access is always allowed.
97 // The service does NOT assume ownership of the policy, it is the callers 104 // The service does NOT assume ownership of the policy, it is the callers
98 // responsibility to ensure that the pointer remains valid while set. 105 // responsibility to ensure that the pointer remains valid while set.
99 AppCachePolicy* appcache_policy() const { return appcache_policy_; } 106 AppCachePolicy* appcache_policy() const { return appcache_policy_; }
100 void set_appcache_policy(AppCachePolicy* policy) { 107 void set_appcache_policy(AppCachePolicy* policy) {
101 appcache_policy_ = policy; 108 appcache_policy_ = policy;
102 } 109 }
103 110
104 quota::SpecialStoragePolicy* special_storage_policy() const { 111 quota::SpecialStoragePolicy* special_storage_policy() const {
105 return special_storage_policy_.get(); 112 return special_storage_policy_.get();
106 } 113 }
107 void set_special_storage_policy(quota::SpecialStoragePolicy* policy); 114 void set_special_storage_policy(quota::SpecialStoragePolicy* policy);
108 115
109 quota::QuotaManagerProxy* quota_manager_proxy() const { 116 quota::QuotaManagerProxy* quota_manager_proxy() const {
110 return quota_manager_proxy_.get(); 117 return quota_manager_proxy_.get();
111 } 118 }
112 119
120 AppCacheQuotaClient* quota_client() const {
121 return quota_client_;
122 }
123
113 // Each child process in chrome uses a distinct backend instance. 124 // Each child process in chrome uses a distinct backend instance.
114 // See chrome/browser/AppCacheDispatcherHost. 125 // See chrome/browser/AppCacheDispatcherHost.
115 void RegisterBackend(AppCacheBackendImpl* backend_impl); 126 void RegisterBackend(AppCacheBackendImpl* backend_impl);
116 void UnregisterBackend(AppCacheBackendImpl* backend_impl); 127 void UnregisterBackend(AppCacheBackendImpl* backend_impl);
117 AppCacheBackendImpl* GetBackend(int id) const { 128 AppCacheBackendImpl* GetBackend(int id) const {
118 BackendMap::const_iterator it = backends_.find(id); 129 BackendMap::const_iterator it = backends_.find(id);
119 return (it != backends_.end()) ? it->second : NULL; 130 return (it != backends_.end()) ? it->second : NULL;
120 } 131 }
121 132
122 AppCacheStorage* storage() const { return storage_.get(); } 133 AppCacheStorage* storage() const { return storage_.get(); }
123 134
124 protected: 135 protected:
136 friend class AppCacheStorageImplTest;
137 friend class AppCacheServiceTest;
138
125 class AsyncHelper; 139 class AsyncHelper;
126 class CanHandleOfflineHelper; 140 class CanHandleOfflineHelper;
127 class DeleteHelper; 141 class DeleteHelper;
142 class DeleteOriginHelper;
128 class GetInfoHelper; 143 class GetInfoHelper;
129 144
130 typedef std::set<AsyncHelper*> PendingAsyncHelpers; 145 typedef std::set<AsyncHelper*> PendingAsyncHelpers;
131 typedef std::map<int, AppCacheBackendImpl*> BackendMap; 146 typedef std::map<int, AppCacheBackendImpl*> BackendMap;
132 147
133 AppCachePolicy* appcache_policy_; 148 AppCachePolicy* appcache_policy_;
149 AppCacheQuotaClient* quota_client_;
134 scoped_ptr<AppCacheStorage> storage_; 150 scoped_ptr<AppCacheStorage> storage_;
135 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; 151 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
136 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; 152 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_;
137 PendingAsyncHelpers pending_helpers_; 153 PendingAsyncHelpers pending_helpers_;
138 BackendMap backends_; // One 'backend' per child process. 154 BackendMap backends_; // One 'backend' per child process.
139 // Context for use during cache updates. 155 // Context for use during cache updates.
140 net::URLRequestContext* request_context_; 156 net::URLRequestContext* request_context_;
141 157
142 DISALLOW_COPY_AND_ASSIGN(AppCacheService); 158 DISALLOW_COPY_AND_ASSIGN(AppCacheService);
143 }; 159 };
144 160
145 } // namespace appcache 161 } // namespace appcache
146 162
147 #endif // WEBKIT_APPCACHE_APPCACHE_SERVICE_H_ 163 #endif // WEBKIT_APPCACHE_APPCACHE_SERVICE_H_
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_quota_client_unittest.cc ('k') | webkit/appcache/appcache_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698