| 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 17 matching lines...) Expand all Loading... |
| 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 Loading... |
| 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 void DeleteAppCachesForOrigin(const GURL& origin, |
| 91 net::CompletionCallback* callback); |
| 92 |
| 87 // Context for use during cache updates, should only be accessed | 93 // 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, | 94 // 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 | 95 // it is the callers responsibility to ensure that the pointer |
| 90 // remains valid while set. | 96 // remains valid while set. |
| 91 net::URLRequestContext* request_context() const { return request_context_; } | 97 net::URLRequestContext* request_context() const { return request_context_; } |
| 92 void set_request_context(net::URLRequestContext* context) { | 98 void set_request_context(net::URLRequestContext* context) { |
| 93 request_context_ = context; | 99 request_context_ = context; |
| 94 } | 100 } |
| 95 | 101 |
| 96 // The appcache policy, may be null, in which case access is always allowed. | 102 // 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 | 103 // The service does NOT assume ownership of the policy, it is the callers |
| 98 // responsibility to ensure that the pointer remains valid while set. | 104 // responsibility to ensure that the pointer remains valid while set. |
| 99 AppCachePolicy* appcache_policy() const { return appcache_policy_; } | 105 AppCachePolicy* appcache_policy() const { return appcache_policy_; } |
| 100 void set_appcache_policy(AppCachePolicy* policy) { | 106 void set_appcache_policy(AppCachePolicy* policy) { |
| 101 appcache_policy_ = policy; | 107 appcache_policy_ = policy; |
| 102 } | 108 } |
| 103 | 109 |
| 104 quota::SpecialStoragePolicy* special_storage_policy() const { | 110 quota::SpecialStoragePolicy* special_storage_policy() const { |
| 105 return special_storage_policy_.get(); | 111 return special_storage_policy_.get(); |
| 106 } | 112 } |
| 107 void set_special_storage_policy(quota::SpecialStoragePolicy* policy); | 113 void set_special_storage_policy(quota::SpecialStoragePolicy* policy); |
| 108 | 114 |
| 109 quota::QuotaManagerProxy* quota_manager_proxy() const { | 115 quota::QuotaManagerProxy* quota_manager_proxy() const { |
| 110 return quota_manager_proxy_.get(); | 116 return quota_manager_proxy_.get(); |
| 111 } | 117 } |
| 112 | 118 |
| 119 AppCacheQuotaClient* quota_client() const { |
| 120 return quota_client_; |
| 121 } |
| 122 |
| 113 // Each child process in chrome uses a distinct backend instance. | 123 // Each child process in chrome uses a distinct backend instance. |
| 114 // See chrome/browser/AppCacheDispatcherHost. | 124 // See chrome/browser/AppCacheDispatcherHost. |
| 115 void RegisterBackend(AppCacheBackendImpl* backend_impl); | 125 void RegisterBackend(AppCacheBackendImpl* backend_impl); |
| 116 void UnregisterBackend(AppCacheBackendImpl* backend_impl); | 126 void UnregisterBackend(AppCacheBackendImpl* backend_impl); |
| 117 AppCacheBackendImpl* GetBackend(int id) const { | 127 AppCacheBackendImpl* GetBackend(int id) const { |
| 118 BackendMap::const_iterator it = backends_.find(id); | 128 BackendMap::const_iterator it = backends_.find(id); |
| 119 return (it != backends_.end()) ? it->second : NULL; | 129 return (it != backends_.end()) ? it->second : NULL; |
| 120 } | 130 } |
| 121 | 131 |
| 122 AppCacheStorage* storage() const { return storage_.get(); } | 132 AppCacheStorage* storage() const { return storage_.get(); } |
| 123 | 133 |
| 124 protected: | 134 protected: |
| 125 class AsyncHelper; | 135 class AsyncHelper; |
| 126 class CanHandleOfflineHelper; | 136 class CanHandleOfflineHelper; |
| 127 class DeleteHelper; | 137 class DeleteHelper; |
| 138 class DeleteOriginHelper; |
| 128 class GetInfoHelper; | 139 class GetInfoHelper; |
| 129 | 140 |
| 130 typedef std::set<AsyncHelper*> PendingAsyncHelpers; | 141 typedef std::set<AsyncHelper*> PendingAsyncHelpers; |
| 131 typedef std::map<int, AppCacheBackendImpl*> BackendMap; | 142 typedef std::map<int, AppCacheBackendImpl*> BackendMap; |
| 132 | 143 |
| 133 AppCachePolicy* appcache_policy_; | 144 AppCachePolicy* appcache_policy_; |
| 145 AppCacheQuotaClient* quota_client_; |
| 134 scoped_ptr<AppCacheStorage> storage_; | 146 scoped_ptr<AppCacheStorage> storage_; |
| 135 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 147 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
| 136 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 148 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; |
| 137 PendingAsyncHelpers pending_helpers_; | 149 PendingAsyncHelpers pending_helpers_; |
| 138 BackendMap backends_; // One 'backend' per child process. | 150 BackendMap backends_; // One 'backend' per child process. |
| 139 // Context for use during cache updates. | 151 // Context for use during cache updates. |
| 140 net::URLRequestContext* request_context_; | 152 net::URLRequestContext* request_context_; |
| 141 | 153 |
| 142 DISALLOW_COPY_AND_ASSIGN(AppCacheService); | 154 DISALLOW_COPY_AND_ASSIGN(AppCacheService); |
| 143 }; | 155 }; |
| 144 | 156 |
| 145 } // namespace appcache | 157 } // namespace appcache |
| 146 | 158 |
| 147 #endif // WEBKIT_APPCACHE_APPCACHE_SERVICE_H_ | 159 #endif // WEBKIT_APPCACHE_APPCACHE_SERVICE_H_ |
| OLD | NEW |