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_HOST_H_ | 5 #ifndef WEBKIT_APPCACHE_APPCACHE_HOST_H_ |
6 #define WEBKIT_APPCACHE_APPCACHE_HOST_H_ | 6 #define WEBKIT_APPCACHE_APPCACHE_HOST_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 int host_id() const { return host_id_; } | 125 int host_id() const { return host_id_; } |
126 AppCacheService* service() const { return service_; } | 126 AppCacheService* service() const { return service_; } |
127 AppCacheFrontend* frontend() const { return frontend_; } | 127 AppCacheFrontend* frontend() const { return frontend_; } |
128 AppCache* associated_cache() const { return associated_cache_.get(); } | 128 AppCache* associated_cache() const { return associated_cache_.get(); } |
129 | 129 |
130 bool is_selection_pending() const { | 130 bool is_selection_pending() const { |
131 return pending_selected_cache_id_ != kNoCacheId || | 131 return pending_selected_cache_id_ != kNoCacheId || |
132 !pending_selected_manifest_url_.is_empty(); | 132 !pending_selected_manifest_url_.is_empty(); |
133 } | 133 } |
134 | 134 |
| 135 const GURL& first_party_url() const { return first_party_url_; } |
| 136 |
135 private: | 137 private: |
136 Status GetStatus(); | 138 Status GetStatus(); |
137 void LoadSelectedCache(int64 cache_id); | 139 void LoadSelectedCache(int64 cache_id); |
138 void LoadOrCreateGroup(const GURL& manifest_url); | 140 void LoadOrCreateGroup(const GURL& manifest_url); |
139 | 141 |
140 // AppCacheStorage::Delegate impl | 142 // AppCacheStorage::Delegate impl |
141 virtual void OnCacheLoaded(AppCache* cache, int64 cache_id); | 143 virtual void OnCacheLoaded(AppCache* cache, int64 cache_id); |
142 virtual void OnGroupLoaded(AppCacheGroup* group, | 144 virtual void OnGroupLoaded(AppCacheGroup* group, |
143 const GURL& manifest_url); | 145 const GURL& manifest_url); |
144 | 146 |
145 void FinishCacheSelection(AppCache* cache, AppCacheGroup* group); | 147 void FinishCacheSelection(AppCache* cache, AppCacheGroup* group); |
146 void DoPendingGetStatus(); | 148 void DoPendingGetStatus(); |
147 void DoPendingStartUpdate(); | 149 void DoPendingStartUpdate(); |
148 void DoPendingSwapCache(); | 150 void DoPendingSwapCache(); |
149 | 151 |
150 void ObserveGroupBeingUpdated(AppCacheGroup* group); | 152 void ObserveGroupBeingUpdated(AppCacheGroup* group); |
151 | 153 |
152 // AppCacheGroup::UpdateObserver methods. | 154 // AppCacheGroup::UpdateObserver methods. |
153 virtual void OnContentBlocked(AppCacheGroup* group); | |
154 virtual void OnUpdateComplete(AppCacheGroup* group); | 155 virtual void OnUpdateComplete(AppCacheGroup* group); |
155 | 156 |
156 // Returns true if this host is for a dedicated worker context. | 157 // Returns true if this host is for a dedicated worker context. |
157 bool is_for_dedicated_worker() const { | 158 bool is_for_dedicated_worker() const { |
158 return parent_host_id_ != kNoHostId; | 159 return parent_host_id_ != kNoHostId; |
159 } | 160 } |
160 | 161 |
161 // Returns the parent context's host instance. This is only valid | 162 // Returns the parent context's host instance. This is only valid |
162 // to call when this instance is_for_dedicated_worker. | 163 // to call when this instance is_for_dedicated_worker. |
163 AppCacheHost* GetParentAppCacheHost() const; | 164 AppCacheHost* GetParentAppCacheHost() const; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 // Tells if info about associated cache is pending. Info is pending | 239 // Tells if info about associated cache is pending. Info is pending |
239 // when update job has not returned success yet. | 240 // when update job has not returned success yet. |
240 bool associated_cache_info_pending_; | 241 bool associated_cache_info_pending_; |
241 | 242 |
242 // List of objects observing us. | 243 // List of objects observing us. |
243 ObserverList<Observer> observers_; | 244 ObserverList<Observer> observers_; |
244 | 245 |
245 // Used to inform the QuotaManager of what origins are currently in use. | 246 // Used to inform the QuotaManager of what origins are currently in use. |
246 GURL origin_in_use_; | 247 GURL origin_in_use_; |
247 | 248 |
| 249 // First party url to be used in policy checks. |
| 250 GURL first_party_url_; |
| 251 |
248 friend class AppCacheRequestHandlerTest; | 252 friend class AppCacheRequestHandlerTest; |
249 friend class AppCacheUpdateJobTest; | 253 friend class AppCacheUpdateJobTest; |
250 FRIEND_TEST_ALL_PREFIXES(AppCacheTest, CleanupUnusedCache); | 254 FRIEND_TEST_ALL_PREFIXES(AppCacheTest, CleanupUnusedCache); |
251 FRIEND_TEST_ALL_PREFIXES(AppCacheGroupTest, CleanupUnusedGroup); | 255 FRIEND_TEST_ALL_PREFIXES(AppCacheGroupTest, CleanupUnusedGroup); |
252 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, Basic); | 256 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, Basic); |
253 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, SelectNoCache); | 257 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, SelectNoCache); |
254 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, ForeignEntry); | 258 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, ForeignEntry); |
255 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, FailedCacheLoad); | 259 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, FailedCacheLoad); |
256 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, FailedGroupLoad); | 260 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, FailedGroupLoad); |
257 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, SetSwappableCache); | 261 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, SetSwappableCache); |
258 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, ForDedicatedWorker); | 262 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, ForDedicatedWorker); |
| 263 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, SelectCacheAllowed); |
| 264 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, SelectCacheBlocked); |
259 FRIEND_TEST_ALL_PREFIXES(AppCacheGroupTest, QueueUpdate); | 265 FRIEND_TEST_ALL_PREFIXES(AppCacheGroupTest, QueueUpdate); |
260 | 266 |
261 DISALLOW_COPY_AND_ASSIGN(AppCacheHost); | 267 DISALLOW_COPY_AND_ASSIGN(AppCacheHost); |
262 }; | 268 }; |
263 | 269 |
264 } // namespace appcache | 270 } // namespace appcache |
265 | 271 |
266 #endif // WEBKIT_APPCACHE_APPCACHE_HOST_H_ | 272 #endif // WEBKIT_APPCACHE_APPCACHE_HOST_H_ |
OLD | NEW |