| 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" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 13 #include "webkit/appcache/appcache_group.h" | 13 #include "webkit/appcache/appcache_group.h" |
| 14 #include "webkit/appcache/appcache_interfaces.h" | 14 #include "webkit/appcache/appcache_interfaces.h" |
| 15 #include "webkit/appcache/appcache_export.h" | 15 #include "webkit/appcache/appcache_export.h" |
| 16 #include "webkit/appcache/appcache_service.h" | 16 #include "webkit/appcache/appcache_service.h" |
| 17 #include "webkit/appcache/appcache_storage.h" | 17 #include "webkit/appcache/appcache_storage.h" |
| 18 #include "webkit/glue/resource_type.h" | 18 #include "webkit/glue/resource_type.h" |
| 19 | 19 |
| 20 namespace net { | 20 namespace net { |
| 21 class URLRequest; | 21 class URLRequest; |
| 22 } // namespace net | 22 } // namespace net |
| 23 | 23 |
| 24 namespace appcache { | 24 namespace appcache { |
| 25 | 25 |
| 26 class AppCache; | 26 class AppCache; |
| 27 class AppCacheFrontend; | 27 class AppCacheFrontend; |
| 28 class AppCacheRequestHandler; | 28 class AppCacheRequestHandler; |
| 29 | 29 |
| 30 typedef Callback2<Status, void*>::Type GetStatusCallback; | 30 typedef base::Callback<void(Status, void*)> GetStatusCallback; |
| 31 typedef Callback2<bool, void*>::Type StartUpdateCallback; | 31 typedef base::Callback<void(bool, void*)> StartUpdateCallback; |
| 32 typedef Callback2<bool, void*>::Type SwapCacheCallback; | 32 typedef base::Callback<void(bool, void*)> SwapCacheCallback; |
| 33 | 33 |
| 34 // Server-side representation of an application cache host. | 34 // Server-side representation of an application cache host. |
| 35 class APPCACHE_EXPORT AppCacheHost : public AppCacheStorage::Delegate, | 35 class APPCACHE_EXPORT AppCacheHost : public AppCacheStorage::Delegate, |
| 36 public AppCacheGroup::UpdateObserver { | 36 public AppCacheGroup::UpdateObserver { |
| 37 public: | 37 public: |
| 38 | 38 |
| 39 class APPCACHE_EXPORT Observer { | 39 class APPCACHE_EXPORT Observer { |
| 40 public: | 40 public: |
| 41 // Called just after the cache selection algorithm completes. | 41 // Called just after the cache selection algorithm completes. |
| 42 virtual void OnCacheSelectionComplete(AppCacheHost* host) = 0; | 42 virtual void OnCacheSelectionComplete(AppCacheHost* host) = 0; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 58 | 58 |
| 59 // Support for cache selection and scriptable method calls. | 59 // Support for cache selection and scriptable method calls. |
| 60 void SelectCache(const GURL& document_url, | 60 void SelectCache(const GURL& document_url, |
| 61 const int64 cache_document_was_loaded_from, | 61 const int64 cache_document_was_loaded_from, |
| 62 const GURL& manifest_url); | 62 const GURL& manifest_url); |
| 63 void SelectCacheForWorker(int parent_process_id, | 63 void SelectCacheForWorker(int parent_process_id, |
| 64 int parent_host_id); | 64 int parent_host_id); |
| 65 void SelectCacheForSharedWorker(int64 appcache_id); | 65 void SelectCacheForSharedWorker(int64 appcache_id); |
| 66 void MarkAsForeignEntry(const GURL& document_url, | 66 void MarkAsForeignEntry(const GURL& document_url, |
| 67 int64 cache_document_was_loaded_from); | 67 int64 cache_document_was_loaded_from); |
| 68 void GetStatusWithCallback(GetStatusCallback* callback, | 68 void GetStatusWithCallback(const GetStatusCallback& callback, |
| 69 void* callback_param); | 69 void* callback_param); |
| 70 void StartUpdateWithCallback(StartUpdateCallback* callback, | 70 void StartUpdateWithCallback(const StartUpdateCallback& callback, |
| 71 void* callback_param); | 71 void* callback_param); |
| 72 void SwapCacheWithCallback(SwapCacheCallback* callback, | 72 void SwapCacheWithCallback(const SwapCacheCallback& callback, |
| 73 void* callback_param); | 73 void* callback_param); |
| 74 | 74 |
| 75 // Called prior to the main resource load. When the system contains multiple | 75 // Called prior to the main resource load. When the system contains multiple |
| 76 // candidates for a main resource load, the appcache preferred by the host | 76 // candidates for a main resource load, the appcache preferred by the host |
| 77 // that created this host is used to break ties. | 77 // that created this host is used to break ties. |
| 78 void SetSpawningHostId(int spawning_process_id, int spawning_host_id); | 78 void SetSpawningHostId(int spawning_process_id, int spawning_host_id); |
| 79 | 79 |
| 80 // May return NULL if the spawning host context has been closed, or if a | 80 // May return NULL if the spawning host context has been closed, or if a |
| 81 // spawning host context was never identified. | 81 // spawning host context was never identified. |
| 82 const AppCacheHost* GetSpawningHost() const; | 82 const AppCacheHost* GetSpawningHost() const; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 212 |
| 213 // A new master entry to be added to the cache, may be empty. | 213 // A new master entry to be added to the cache, may be empty. |
| 214 GURL new_master_entry_url_; | 214 GURL new_master_entry_url_; |
| 215 | 215 |
| 216 // The frontend proxy to deliver notifications to the child process. | 216 // The frontend proxy to deliver notifications to the child process. |
| 217 AppCacheFrontend* frontend_; | 217 AppCacheFrontend* frontend_; |
| 218 | 218 |
| 219 // Our central service object. | 219 // Our central service object. |
| 220 AppCacheService* service_; | 220 AppCacheService* service_; |
| 221 | 221 |
| 222 // Since these are synchronous scriptable api calls in the client, | 222 // Since these are synchronous scriptable API calls in the client, there can |
| 223 // there can only be one type of callback pending. | 223 // only be one type of callback pending. Also, we have to wait until we have a |
| 224 // Also, we have to wait until we have a cache selection prior | 224 // cache selection prior to responding to these calls, as cache selection |
| 225 // to responding to these calls, as cache selection involves | 225 // involves async loading of a cache or a group from storage. |
| 226 // async loading of a cache or a group from storage. | 226 GetStatusCallback pending_get_status_callback_; |
| 227 GetStatusCallback* pending_get_status_callback_; | 227 StartUpdateCallback pending_start_update_callback_; |
| 228 StartUpdateCallback* pending_start_update_callback_; | 228 SwapCacheCallback pending_swap_cache_callback_; |
| 229 SwapCacheCallback* pending_swap_cache_callback_; | |
| 230 void* pending_callback_param_; | 229 void* pending_callback_param_; |
| 231 | 230 |
| 232 // True if a fallback resource was delivered as the main resource. | 231 // True if a fallback resource was delivered as the main resource. |
| 233 bool main_resource_was_fallback_; | 232 bool main_resource_was_fallback_; |
| 234 GURL fallback_url_; | 233 GURL fallback_url_; |
| 235 | 234 |
| 236 // True if requests for this host were blocked by a policy. | 235 // True if requests for this host were blocked by a policy. |
| 237 bool main_resource_blocked_; | 236 bool main_resource_blocked_; |
| 238 GURL blocked_manifest_url_; | 237 GURL blocked_manifest_url_; |
| 239 | 238 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 264 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, SelectCacheAllowed); | 263 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, SelectCacheAllowed); |
| 265 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, SelectCacheBlocked); | 264 FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, SelectCacheBlocked); |
| 266 FRIEND_TEST_ALL_PREFIXES(AppCacheGroupTest, QueueUpdate); | 265 FRIEND_TEST_ALL_PREFIXES(AppCacheGroupTest, QueueUpdate); |
| 267 | 266 |
| 268 DISALLOW_COPY_AND_ASSIGN(AppCacheHost); | 267 DISALLOW_COPY_AND_ASSIGN(AppCacheHost); |
| 269 }; | 268 }; |
| 270 | 269 |
| 271 } // namespace appcache | 270 } // namespace appcache |
| 272 | 271 |
| 273 #endif // WEBKIT_APPCACHE_APPCACHE_HOST_H_ | 272 #endif // WEBKIT_APPCACHE_APPCACHE_HOST_H_ |
| OLD | NEW |