OLD | NEW |
---|---|
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 } | 66 } |
67 | 67 |
68 // Determines if a request for 'url' can be satisfied while offline. | 68 // Determines if a request for 'url' can be satisfied while offline. |
69 // This method always completes asynchronously. | 69 // This method always completes asynchronously. |
70 void CanHandleMainResourceOffline(const GURL& url, | 70 void CanHandleMainResourceOffline(const GURL& url, |
71 net::CompletionCallback* callback); | 71 net::CompletionCallback* callback); |
72 | 72 |
73 // Populates 'collection' with info about all of the appcaches stored | 73 // Populates 'collection' with info about all of the appcaches stored |
74 // within the service, 'callback' is invoked upon completion. The service | 74 // within the service, 'callback' is invoked upon completion. The service |
75 // acquires a reference to the 'collection' until until completion. | 75 // acquires a reference to the 'collection' until until completion. |
76 // This method always completes asynchronously. | 76 // This method always completes asynchronously. (virtual for unittesting) |
77 void GetAllAppCacheInfo(AppCacheInfoCollection* collection, | 77 virtual void GetAllAppCacheInfo(AppCacheInfoCollection* collection, |
78 net::CompletionCallback* callback); | 78 net::CompletionCallback* callback); |
79 | 79 |
80 // Deletes the group identified by 'manifest_url', 'callback' is | 80 // Deletes the group identified by 'manifest_url', 'callback' is invoked upon |
81 // invoked upon completion. Upon completion, the cache group and | 81 // completion. Upon completion, the cache group and any resources within the |
82 // any resources within the group are no longer loadable and all | 82 // group are no longer loadable and all subresource loads for pages associated |
83 // subresource loads for pages associated with a deleted group | 83 // with a deleted group will fail. This method always completes |
84 // will fail. This method always completes asynchronously. | 84 // asynchronously. (virtual for unittesting) |
85 void DeleteAppCacheGroup(const GURL& manifest_url, | 85 virtual void DeleteAppCacheGroup(const GURL& manifest_url, |
86 net::CompletionCallback* callback); | 86 net::CompletionCallback* callback); |
87 | 87 |
88 // Deletes all appcaches for the origin, 'callback' is invoked upon | 88 // Deletes all appcaches for the origin, 'callback' is invoked upon |
89 // completion. This method always completes asynchronously. | 89 // completion. This method always completes asynchronously. |
90 // (virtual for unittesting) | 90 // (virtual for unittesting) |
91 virtual void DeleteAppCachesForOrigin(const GURL& origin, | 91 virtual void DeleteAppCachesForOrigin(const GURL& origin, |
92 net::CompletionCallback* callback); | 92 net::CompletionCallback* callback); |
93 | 93 |
94 // Context for use during cache updates, should only be accessed | 94 // Context for use during cache updates, should only be accessed |
95 // 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, |
(...skipping 29 matching lines...) Expand all Loading... | |
125 // See chrome/browser/AppCacheDispatcherHost. | 125 // See chrome/browser/AppCacheDispatcherHost. |
126 void RegisterBackend(AppCacheBackendImpl* backend_impl); | 126 void RegisterBackend(AppCacheBackendImpl* backend_impl); |
127 void UnregisterBackend(AppCacheBackendImpl* backend_impl); | 127 void UnregisterBackend(AppCacheBackendImpl* backend_impl); |
128 AppCacheBackendImpl* GetBackend(int id) const { | 128 AppCacheBackendImpl* GetBackend(int id) const { |
129 BackendMap::const_iterator it = backends_.find(id); | 129 BackendMap::const_iterator it = backends_.find(id); |
130 return (it != backends_.end()) ? it->second : NULL; | 130 return (it != backends_.end()) ? it->second : NULL; |
131 } | 131 } |
132 | 132 |
133 AppCacheStorage* storage() const { return storage_.get(); } | 133 AppCacheStorage* storage() const { return storage_.get(); } |
134 | 134 |
135 bool clear_local_state_on_exit() const { return clear_local_state_on_exit_; } | |
136 void set_clear_local_state_on_exit(bool clear_local_state_on_exit) { | |
137 clear_local_state_on_exit_ = clear_local_state_on_exit; } | |
138 | |
135 protected: | 139 protected: |
136 friend class AppCacheStorageImplTest; | 140 friend class AppCacheStorageImplTest; |
137 friend class AppCacheServiceTest; | 141 friend class AppCacheServiceTest; |
138 | 142 |
139 class AsyncHelper; | 143 class AsyncHelper; |
140 class CanHandleOfflineHelper; | 144 class CanHandleOfflineHelper; |
141 class DeleteHelper; | 145 class DeleteHelper; |
142 class DeleteOriginHelper; | 146 class DeleteOriginHelper; |
143 class GetInfoHelper; | 147 class GetInfoHelper; |
144 | 148 |
145 typedef std::set<AsyncHelper*> PendingAsyncHelpers; | 149 typedef std::set<AsyncHelper*> PendingAsyncHelpers; |
146 typedef std::map<int, AppCacheBackendImpl*> BackendMap; | 150 typedef std::map<int, AppCacheBackendImpl*> BackendMap; |
147 | 151 |
148 AppCachePolicy* appcache_policy_; | 152 AppCachePolicy* appcache_policy_; |
149 AppCacheQuotaClient* quota_client_; | 153 AppCacheQuotaClient* quota_client_; |
154 // special_storage_policy_ must outlive storage_; ~AppCacheStorageImpl | |
155 // accesses special_storage_policy_. | |
michaeln
2011/07/14 22:53:16
right... that's pretty subtle... commenting the da
marja(google)
2011/07/15 11:03:42
Done.
| |
156 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | |
150 scoped_ptr<AppCacheStorage> storage_; | 157 scoped_ptr<AppCacheStorage> storage_; |
151 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | |
152 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 158 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; |
153 PendingAsyncHelpers pending_helpers_; | 159 PendingAsyncHelpers pending_helpers_; |
154 BackendMap backends_; // One 'backend' per child process. | 160 BackendMap backends_; // One 'backend' per child process. |
155 // Context for use during cache updates. | 161 // Context for use during cache updates. |
156 net::URLRequestContext* request_context_; | 162 net::URLRequestContext* request_context_; |
163 bool clear_local_state_on_exit_; | |
157 | 164 |
158 DISALLOW_COPY_AND_ASSIGN(AppCacheService); | 165 DISALLOW_COPY_AND_ASSIGN(AppCacheService); |
159 }; | 166 }; |
160 | 167 |
161 } // namespace appcache | 168 } // namespace appcache |
162 | 169 |
163 #endif // WEBKIT_APPCACHE_APPCACHE_SERVICE_H_ | 170 #endif // WEBKIT_APPCACHE_APPCACHE_SERVICE_H_ |
OLD | NEW |