Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / webkit / browser / appcache / appcache_service.h
index 51647d1..c800e71 100644 (file)
@@ -12,6 +12,8 @@
 #include "base/memory/ref_counted.h"
 #include "base/memory/scoped_ptr.h"
 #include "base/observer_list.h"
+#include "base/time/time.h"
+#include "base/timer/timer.h"
 #include "net/base/completion_callback.h"
 #include "net/base/net_errors.h"
 #include "webkit/browser/appcache/appcache_storage.h"
@@ -99,9 +101,9 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheService {
     observers_.RemoveObserver(observer);
   }
 
-  // For use in a very specific failure mode to reboot the appcache system
+  // For use in catastrophic failure modes to reboot the appcache system
   // without relaunching the browser.
-  void Reinitialize();
+  void ScheduleReinitialize();
 
   // Purges any memory not needed.
   void PurgeMemory() {
@@ -201,6 +203,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheService {
  protected:
   friend class AppCacheStorageImplTest;
   friend class AppCacheServiceTest;
+  FRIEND_TEST_ALL_PREFIXES(AppCacheServiceTest, ScheduleReinitialize);
 
   class AsyncHelper;
   class CanHandleOfflineHelper;
@@ -212,6 +215,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheService {
   typedef std::set<AsyncHelper*> PendingAsyncHelpers;
   typedef std::map<int, AppCacheBackendImpl*> BackendMap;
 
+  void Reinitialize();
+
   base::FilePath cache_directory_;
   scoped_refptr<base::MessageLoopProxy> db_thread_;
   scoped_refptr<base::MessageLoopProxy> cache_thread_;
@@ -227,7 +232,9 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheService {
   net::URLRequestContext* request_context_;
   // If true, nothing (not even session-only data) should be deleted on exit.
   bool force_keep_session_state_;
-  bool was_reinitialized_;
+  base::Time last_reinit_time_;
+  base::TimeDelta next_reinit_delay_;
+  base::OneShotTimer<AppCacheService> reinit_timer_;
   ObserverList<Observer> observers_;
 
   DISALLOW_COPY_AND_ASSIGN(AppCacheService);