| 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 NET_DISK_CACHE_CACHE_UTIL_H_ | 5 #ifndef NET_DISK_CACHE_CACHE_UTIL_H_ |
| 6 #define NET_DISK_CACHE_CACHE_UTIL_H_ | 6 #define NET_DISK_CACHE_CACHE_UTIL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "net/base/net_export.h" | 9 #include "net/base/net_export.h" |
| 10 #include "net/disk_cache/disk_cache.h" | 10 #include "net/disk_cache/disk_cache.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 NET_EXPORT_PRIVATE void DeleteCache(const base::FilePath& path, | 29 NET_EXPORT_PRIVATE void DeleteCache(const base::FilePath& path, |
| 30 bool remove_folder); | 30 bool remove_folder); |
| 31 | 31 |
| 32 // Deletes a cache file. | 32 // Deletes a cache file. |
| 33 NET_EXPORT_PRIVATE bool DeleteCacheFile(const base::FilePath& name); | 33 NET_EXPORT_PRIVATE bool DeleteCacheFile(const base::FilePath& name); |
| 34 | 34 |
| 35 // Renames cache directory synchronously and fires off a background cleanup | 35 // Renames cache directory synchronously and fires off a background cleanup |
| 36 // task. Used by cache creator itself or by backends for self-restart on error. | 36 // task. Used by cache creator itself or by backends for self-restart on error. |
| 37 bool DelayedCacheCleanup(const base::FilePath& full_path); | 37 bool DelayedCacheCleanup(const base::FilePath& full_path); |
| 38 | 38 |
| 39 // Builds an instance of the backend depending on platform, type, experiments | |
| 40 // etc. Takes care of the retry state. This object will self-destroy when | |
| 41 // finished. | |
| 42 class NET_EXPORT_PRIVATE CacheCreator { | |
| 43 public: | |
| 44 CacheCreator(const base::FilePath& path, bool force, int max_bytes, | |
| 45 net::CacheType type, uint32 flags, | |
| 46 base::MessageLoopProxy* thread, net::NetLog* net_log, | |
| 47 disk_cache::Backend** backend, | |
| 48 const net::CompletionCallback& callback); | |
| 49 | |
| 50 // Creates the backend. | |
| 51 int Run(); | |
| 52 | |
| 53 private: | |
| 54 ~CacheCreator(); | |
| 55 | |
| 56 void DoCallback(int result); | |
| 57 | |
| 58 void OnIOComplete(int result); | |
| 59 | |
| 60 const base::FilePath& path_; | |
| 61 bool force_; | |
| 62 bool retry_; | |
| 63 int max_bytes_; | |
| 64 net::CacheType type_; | |
| 65 uint32 flags_; | |
| 66 scoped_refptr<base::MessageLoopProxy> thread_; | |
| 67 disk_cache::Backend** backend_; | |
| 68 net::CompletionCallback callback_; | |
| 69 disk_cache::Backend* created_cache_; | |
| 70 net::NetLog* net_log_; | |
| 71 | |
| 72 DISALLOW_COPY_AND_ASSIGN(CacheCreator); | |
| 73 }; | |
| 74 | |
| 75 } // namespace disk_cache | 39 } // namespace disk_cache |
| 76 | 40 |
| 77 #endif // NET_DISK_CACHE_CACHE_UTIL_H_ | 41 #endif // NET_DISK_CACHE_CACHE_UTIL_H_ |
| OLD | NEW |