OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ | 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ |
6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ | 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
| 9 #include <vector> |
9 | 10 |
10 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" |
13 #include "base/platform_file.h" | 15 #include "base/platform_file.h" |
14 #include "base/task_runner.h" | 16 #include "base/task_runner.h" |
15 #include "base/time.h" | 17 #include "base/time.h" |
16 #include "net/base/completion_callback.h" | 18 #include "net/base/completion_callback.h" |
17 #include "net/disk_cache/simple/simple_entry_format.h" | 19 #include "net/disk_cache/simple/simple_entry_format.h" |
18 | 20 |
19 namespace base { | 21 namespace base { |
20 class SingleThreadTaskRunner; | 22 class SingleThreadTaskRunner; |
21 } | 23 } |
22 | 24 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 58 |
57 // Deletes an entry without first Opening it. Does not check if there is | 59 // Deletes an entry without first Opening it. Does not check if there is |
58 // already an Entry object in memory holding the open files. Be careful! This | 60 // already an Entry object in memory holding the open files. Be careful! This |
59 // is meant to be used by the Backend::DoomEntry() call. |callback| will be | 61 // is meant to be used by the Backend::DoomEntry() call. |callback| will be |
60 // run by |callback_runner|. | 62 // run by |callback_runner|. |
61 static void DoomEntry(const base::FilePath& path, | 63 static void DoomEntry(const base::FilePath& path, |
62 const std::string& key, | 64 const std::string& key, |
63 base::SingleThreadTaskRunner* callback_runner, | 65 base::SingleThreadTaskRunner* callback_runner, |
64 const net::CompletionCallback& callback); | 66 const net::CompletionCallback& callback); |
65 | 67 |
| 68 // Like |DoomEntry()| above. Deletes all entries corresponding to the |
| 69 // |key_hashes|. Succeeds only when all entries are deleted. |
| 70 static void DoomEntrySet(scoped_ptr<std::vector<uint64> > key_hashes, |
| 71 const base::FilePath& path, |
| 72 base::SingleThreadTaskRunner* callback_runner, |
| 73 const net::CompletionCallback& callback); |
| 74 |
66 // N.B. Close(), ReadData() and WriteData() may block on IO. | 75 // N.B. Close(), ReadData() and WriteData() may block on IO. |
67 void Close(); | 76 void Close(); |
68 void ReadData(int index, | 77 void ReadData(int index, |
69 int offset, | 78 int offset, |
70 net::IOBuffer* buf, | 79 net::IOBuffer* buf, |
71 int buf_len, | 80 int buf_len, |
72 const SynchronousOperationCallback& callback); | 81 const SynchronousOperationCallback& callback); |
73 void WriteData(int index, | 82 void WriteData(int index, |
74 int offset, | 83 int offset, |
75 net::IOBuffer* buf, | 84 net::IOBuffer* buf, |
(...skipping 23 matching lines...) Expand all Loading... |
99 | 108 |
100 // Returns a net::Error, i.e. net::OK on success. | 109 // Returns a net::Error, i.e. net::OK on success. |
101 int InitializeForOpen(); | 110 int InitializeForOpen(); |
102 | 111 |
103 // Returns a net::Error, including net::OK on success and net::FILE_EXISTS | 112 // Returns a net::Error, including net::OK on success and net::FILE_EXISTS |
104 // when the entry already exists. | 113 // when the entry already exists. |
105 int InitializeForCreate(); | 114 int InitializeForCreate(); |
106 | 115 |
107 void Doom(); | 116 void Doom(); |
108 | 117 |
| 118 static bool DeleteFilesForEntry(const base::FilePath& path, |
| 119 const std::string& key); |
| 120 |
109 scoped_refptr<base::SingleThreadTaskRunner> callback_runner_; | 121 scoped_refptr<base::SingleThreadTaskRunner> callback_runner_; |
110 const base::FilePath path_; | 122 const base::FilePath path_; |
111 const std::string key_; | 123 const std::string key_; |
112 | 124 |
113 bool initialized_; | 125 bool initialized_; |
114 | 126 |
115 base::Time last_used_; | 127 base::Time last_used_; |
116 base::Time last_modified_; | 128 base::Time last_modified_; |
117 int32 data_size_[kSimpleEntryFileCount]; | 129 int32 data_size_[kSimpleEntryFileCount]; |
118 | 130 |
119 base::PlatformFile files_[kSimpleEntryFileCount]; | 131 base::PlatformFile files_[kSimpleEntryFileCount]; |
120 }; | 132 }; |
121 | 133 |
122 } // namespace disk_cache | 134 } // namespace disk_cache |
123 | 135 |
124 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ | 136 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ |
OLD | NEW |