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 | 11 |
11 namespace base { | 12 namespace base { |
12 class FilePath; | 13 class FilePath; |
13 } | 14 } |
14 | 15 |
15 namespace disk_cache { | 16 namespace disk_cache { |
16 | 17 |
17 // Moves the cache files from the given path to another location. | 18 // Moves the cache files from the given path to another location. |
18 // Fails if the destination exists already, or if it doesn't have | 19 // Fails if the destination exists already, or if it doesn't have |
19 // permission for the operation. This is basically a rename operation | 20 // permission for the operation. This is basically a rename operation |
20 // for the cache directory. Returns true if successful. On ChromeOS, | 21 // for the cache directory. Returns true if successful. On ChromeOS, |
21 // this moves the cache contents, and leaves the empty cache | 22 // this moves the cache contents, and leaves the empty cache |
22 // directory. | 23 // directory. |
23 NET_EXPORT_PRIVATE bool MoveCache(const base::FilePath& from_path, | 24 NET_EXPORT_PRIVATE bool MoveCache(const base::FilePath& from_path, |
24 const base::FilePath& to_path); | 25 const base::FilePath& to_path); |
25 | 26 |
26 // Deletes the cache files stored on |path|, and optionally also attempts to | 27 // Deletes the cache files stored on |path|, and optionally also attempts to |
27 // delete the folder itself. | 28 // delete the folder itself. |
28 NET_EXPORT_PRIVATE void DeleteCache(const base::FilePath& path, | 29 NET_EXPORT_PRIVATE void DeleteCache(const base::FilePath& path, |
29 bool remove_folder); | 30 bool remove_folder); |
30 | 31 |
31 // Deletes a cache file. | 32 // Deletes a cache file. |
32 NET_EXPORT_PRIVATE bool DeleteCacheFile(const base::FilePath& name); | 33 NET_EXPORT_PRIVATE bool DeleteCacheFile(const base::FilePath& name); |
33 | 34 |
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. | |
37 NET_EXPORT_PRIVATE bool DelayedCacheCleanup(const base::FilePath& full_path); | |
rvargas (doing something else)
2013/03/28 03:12:45
why export this?. I don't think we should (unless
pasko-google - do not use
2013/03/28 21:41:42
I am confused. NET_EXPORT and NET_EXPORT_PRIVATE h
rvargas (doing something else)
2013/03/28 22:30:21
They are always the same thing... the idea is that
pasko-google - do not use
2013/03/29 02:20:26
OK, you eliminated my confusion, and I might only
rvargas (doing something else)
2013/03/29 06:49:22
We have more bots building the component build tha
| |
38 | |
39 // Builds an instance of the backend depending on command-line option(s), | |
rvargas (doing something else)
2013/03/28 03:12:45
Don't mention command line options. The _implement
pasko-google - do not use
2013/03/28 21:41:42
Replaced commandline with experiment in the descri
rvargas (doing something else)
2013/03/28 22:30:21
but headers are meant to document interfaces and a
pasko-google - do not use
2013/03/29 02:20:26
Ah, I see. The comment was intended to suggest a c
| |
40 // platform, type, etc. Takes care of the retry state. This object will | |
41 // self-destroy when finished. | |
42 class NET_EXPORT_PRIVATE CacheCreator { | |
rvargas (doing something else)
2013/03/28 03:12:45
As I said somewhere else, I think we should be tes
pasko-google - do not use
2013/03/28 21:41:42
I will try to ignore all the flags on the few forc
| |
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 | |
34 } // namespace disk_cache | 75 } // namespace disk_cache |
35 | 76 |
36 #endif // NET_DISK_CACHE_CACHE_UTIL_H_ | 77 #endif // NET_DISK_CACHE_CACHE_UTIL_H_ |
OLD | NEW |