 Chromium Code Reviews
 Chromium Code Reviews Issue 137493003:
  Appcache::OnCorruptionDetected handling  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 137493003:
  Appcache::OnCorruptionDetected handling  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BROWSER_APPCACHE_APPCACHE_SERVICE_H_ | 5 #ifndef WEBKIT_BROWSER_APPCACHE_APPCACHE_SERVICE_H_ | 
| 6 #define WEBKIT_BROWSER_APPCACHE_APPCACHE_SERVICE_H_ | 6 #define WEBKIT_BROWSER_APPCACHE_APPCACHE_SERVICE_H_ | 
| 7 | 7 | 
| 8 #include <map> | 8 #include <map> | 
| 9 #include <set> | 9 #include <set> | 
| 10 | 10 | 
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" | 
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" | 
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" | 
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" | 
| 15 #include "base/time/time.h" | |
| 16 #include "base/timer/timer.h" | |
| 15 #include "net/base/completion_callback.h" | 17 #include "net/base/completion_callback.h" | 
| 16 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" | 
| 17 #include "webkit/browser/appcache/appcache_storage.h" | 19 #include "webkit/browser/appcache/appcache_storage.h" | 
| 18 #include "webkit/browser/quota/quota_manager_proxy.h" | 20 #include "webkit/browser/quota/quota_manager_proxy.h" | 
| 19 #include "webkit/browser/webkit_storage_browser_export.h" | 21 #include "webkit/browser/webkit_storage_browser_export.h" | 
| 20 #include "webkit/common/appcache/appcache_interfaces.h" | 22 #include "webkit/common/appcache/appcache_interfaces.h" | 
| 21 | 23 | 
| 22 namespace net { | 24 namespace net { | 
| 23 class URLRequestContext; | 25 class URLRequestContext; | 
| 24 } // namespace net | 26 } // namespace net | 
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 base::MessageLoopProxy* cache_thread); | 94 base::MessageLoopProxy* cache_thread); | 
| 93 | 95 | 
| 94 void AddObserver(Observer* observer) { | 96 void AddObserver(Observer* observer) { | 
| 95 observers_.AddObserver(observer); | 97 observers_.AddObserver(observer); | 
| 96 } | 98 } | 
| 97 | 99 | 
| 98 void RemoveObserver(Observer* observer) { | 100 void RemoveObserver(Observer* observer) { | 
| 99 observers_.RemoveObserver(observer); | 101 observers_.RemoveObserver(observer); | 
| 100 } | 102 } | 
| 101 | 103 | 
| 102 // For use in a very specific failure mode to reboot the appcache system | 104 // For use in catastrophic failure modes to reboot the appcache system | 
| 103 // without relaunching the browser. | 105 // without relaunching the browser. | 
| 104 void Reinitialize(); | 106 void ScheduleReinitialize(); | 
| 105 | 107 | 
| 106 // Purges any memory not needed. | 108 // Purges any memory not needed. | 
| 107 void PurgeMemory() { | 109 void PurgeMemory() { | 
| 108 if (storage_) | 110 if (storage_) | 
| 109 storage_->PurgeMemory(); | 111 storage_->PurgeMemory(); | 
| 110 } | 112 } | 
| 111 | 113 | 
| 112 // Determines if a request for 'url' can be satisfied while offline. | 114 // Determines if a request for 'url' can be satisfied while offline. | 
| 113 // This method always completes asynchronously. | 115 // This method always completes asynchronously. | 
| 114 void CanHandleMainResourceOffline(const GURL& url, | 116 void CanHandleMainResourceOffline(const GURL& url, | 
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 | 196 | 
| 195 AppCacheStorage* storage() const { return storage_.get(); } | 197 AppCacheStorage* storage() const { return storage_.get(); } | 
| 196 | 198 | 
| 197 // Disables the exit-time deletion of session-only data. | 199 // Disables the exit-time deletion of session-only data. | 
| 198 void set_force_keep_session_state() { force_keep_session_state_ = true; } | 200 void set_force_keep_session_state() { force_keep_session_state_ = true; } | 
| 199 bool force_keep_session_state() const { return force_keep_session_state_; } | 201 bool force_keep_session_state() const { return force_keep_session_state_; } | 
| 200 | 202 | 
| 201 protected: | 203 protected: | 
| 202 friend class AppCacheStorageImplTest; | 204 friend class AppCacheStorageImplTest; | 
| 203 friend class AppCacheServiceTest; | 205 friend class AppCacheServiceTest; | 
| 206 FRIEND_TEST_ALL_PREFIXES(AppCacheServiceTest, ScheduleReinitialize); | |
| 
jsbell
2014/01/24 21:13:44
Is this necessary if the AppCacheServiceTest class
 
michaeln
2014/01/28 22:12:16
Is is, TEST_F declares/defines a subclass and the
 | |
| 204 | 207 | 
| 205 class AsyncHelper; | 208 class AsyncHelper; | 
| 206 class CanHandleOfflineHelper; | 209 class CanHandleOfflineHelper; | 
| 207 class DeleteHelper; | 210 class DeleteHelper; | 
| 208 class DeleteOriginHelper; | 211 class DeleteOriginHelper; | 
| 209 class GetInfoHelper; | 212 class GetInfoHelper; | 
| 210 class CheckResponseHelper; | 213 class CheckResponseHelper; | 
| 211 | 214 | 
| 212 typedef std::set<AsyncHelper*> PendingAsyncHelpers; | 215 typedef std::set<AsyncHelper*> PendingAsyncHelpers; | 
| 213 typedef std::map<int, AppCacheBackendImpl*> BackendMap; | 216 typedef std::map<int, AppCacheBackendImpl*> BackendMap; | 
| 214 | 217 | 
| 218 void Reinitialize(); | |
| 219 | |
| 215 base::FilePath cache_directory_; | 220 base::FilePath cache_directory_; | 
| 216 scoped_refptr<base::MessageLoopProxy> db_thread_; | 221 scoped_refptr<base::MessageLoopProxy> db_thread_; | 
| 217 scoped_refptr<base::MessageLoopProxy> cache_thread_; | 222 scoped_refptr<base::MessageLoopProxy> cache_thread_; | 
| 218 AppCachePolicy* appcache_policy_; | 223 AppCachePolicy* appcache_policy_; | 
| 219 AppCacheQuotaClient* quota_client_; | 224 AppCacheQuotaClient* quota_client_; | 
| 220 AppCacheExecutableHandlerFactory* handler_factory_; | 225 AppCacheExecutableHandlerFactory* handler_factory_; | 
| 221 scoped_ptr<AppCacheStorage> storage_; | 226 scoped_ptr<AppCacheStorage> storage_; | 
| 222 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 227 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 
| 223 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 228 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 
| 224 PendingAsyncHelpers pending_helpers_; | 229 PendingAsyncHelpers pending_helpers_; | 
| 225 BackendMap backends_; // One 'backend' per child process. | 230 BackendMap backends_; // One 'backend' per child process. | 
| 226 // Context for use during cache updates. | 231 // Context for use during cache updates. | 
| 227 net::URLRequestContext* request_context_; | 232 net::URLRequestContext* request_context_; | 
| 228 // If true, nothing (not even session-only data) should be deleted on exit. | 233 // If true, nothing (not even session-only data) should be deleted on exit. | 
| 229 bool force_keep_session_state_; | 234 bool force_keep_session_state_; | 
| 230 bool was_reinitialized_; | 235 base::Time last_reinit_time_; | 
| 236 base::TimeDelta next_reinit_delay_; | |
| 237 base::OneShotTimer<AppCacheService> reinit_timer_; | |
| 231 ObserverList<Observer> observers_; | 238 ObserverList<Observer> observers_; | 
| 232 | 239 | 
| 233 DISALLOW_COPY_AND_ASSIGN(AppCacheService); | 240 DISALLOW_COPY_AND_ASSIGN(AppCacheService); | 
| 234 }; | 241 }; | 
| 235 | 242 | 
| 236 } // namespace appcache | 243 } // namespace appcache | 
| 237 | 244 | 
| 238 #endif // WEBKIT_BROWSER_APPCACHE_APPCACHE_SERVICE_H_ | 245 #endif // WEBKIT_BROWSER_APPCACHE_APPCACHE_SERVICE_H_ | 
| OLD | NEW |