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 <set> | |
8 #include <string> | 9 #include <string> |
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" |
gavinp
2013/04/17 07:41:18
Need scoped_ptr.h too.
pasko-google - do not use
2013/04/17 19:47:52
why?
| |
13 #include "base/platform_file.h" | 14 #include "base/platform_file.h" |
14 #include "base/task_runner.h" | 15 #include "base/task_runner.h" |
15 #include "base/time.h" | 16 #include "base/time.h" |
16 #include "net/base/completion_callback.h" | 17 #include "net/base/completion_callback.h" |
17 #include "net/disk_cache/simple/simple_entry_format.h" | 18 #include "net/disk_cache/simple/simple_entry_format.h" |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 class SingleThreadTaskRunner; | 21 class SingleThreadTaskRunner; |
21 } | 22 } |
22 | 23 |
(...skipping 21 matching lines...) Expand all Loading... | |
44 | 45 |
45 static void OpenEntry( | 46 static void OpenEntry( |
46 const base::FilePath& path, | 47 const base::FilePath& path, |
47 const std::string& key, | 48 const std::string& key, |
48 const scoped_refptr<base::TaskRunner>& callback_runner, | 49 const scoped_refptr<base::TaskRunner>& callback_runner, |
49 const SynchronousCreationCallback& callback); | 50 const SynchronousCreationCallback& callback); |
50 | 51 |
51 static void CreateEntry( | 52 static void CreateEntry( |
52 const base::FilePath& path, | 53 const base::FilePath& path, |
53 const std::string& key, | 54 const std::string& key, |
54 const scoped_refptr<base::TaskRunner>& callback_runner, | 55 const scoped_refptr<base::TaskRunner>& callback_runner, |
gavinp
2013/04/18 06:11:35
This is why!
| |
55 const SynchronousCreationCallback& callback); | 56 const SynchronousCreationCallback& callback); |
56 | 57 |
57 // Deletes an entry without first Opening it. Does not check if there is | 58 // 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 | 59 // 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 | 60 // is meant to be used by the Backend::DoomEntry() call. |callback| will be |
60 // run by |callback_runner|. | 61 // run by |callback_runner|. |
61 static void DoomEntry(const base::FilePath& path, | 62 static void DoomEntry(const base::FilePath& path, |
62 const std::string& key, | 63 const std::string& key, |
63 scoped_refptr<base::TaskRunner> callback_runner, | 64 scoped_refptr<base::TaskRunner> callback_runner, |
64 const net::CompletionCallback& callback); | 65 const net::CompletionCallback& callback); |
65 | 66 |
67 // Like |DoomEntry()| above. Deletes entry files corresponding to the set of | |
gavinp
2013/04/17 07:41:18
// Like |DoomEntry()| above. Deletes all entries c
pasko-google - do not use
2013/04/17 19:47:52
I wanted to stress the word 'files', but OK. Done.
| |
68 // key hashes: |key_hashes|. | |
69 static void DoomEntrySet(scoped_ptr<std::set<uint64> > key_hashes, | |
70 const base::FilePath& path, | |
71 scoped_refptr<base::TaskRunner> callback_runner, | |
72 const net::CompletionCallback& callback); | |
73 | |
66 // N.B. Close(), ReadData() and WriteData() may block on IO. | 74 // N.B. Close(), ReadData() and WriteData() may block on IO. |
67 void Close(); | 75 void Close(); |
68 void ReadData(int index, | 76 void ReadData(int index, |
69 int offset, | 77 int offset, |
70 net::IOBuffer* buf, | 78 net::IOBuffer* buf, |
71 int buf_len, | 79 int buf_len, |
72 const SynchronousOperationCallback& callback); | 80 const SynchronousOperationCallback& callback); |
73 void WriteData(int index, | 81 void WriteData(int index, |
74 int offset, | 82 int offset, |
75 net::IOBuffer* buf, | 83 net::IOBuffer* buf, |
(...skipping 23 matching lines...) Expand all Loading... | |
99 | 107 |
100 // Returns a net::Error, i.e. net::OK on success. | 108 // Returns a net::Error, i.e. net::OK on success. |
101 int InitializeForOpen(); | 109 int InitializeForOpen(); |
102 | 110 |
103 // Returns a net::Error, including net::OK on success and net::FILE_EXISTS | 111 // Returns a net::Error, including net::OK on success and net::FILE_EXISTS |
104 // when the entry already exists. | 112 // when the entry already exists. |
105 int InitializeForCreate(); | 113 int InitializeForCreate(); |
106 | 114 |
107 void Doom(); | 115 void Doom(); |
108 | 116 |
117 static bool DeleteFilesForEntry(const base::FilePath& path, | |
118 const std::string& key); | |
119 | |
109 scoped_refptr<base::TaskRunner> callback_runner_; | 120 scoped_refptr<base::TaskRunner> callback_runner_; |
110 const base::FilePath path_; | 121 const base::FilePath path_; |
111 const std::string key_; | 122 const std::string key_; |
112 | 123 |
113 bool initialized_; | 124 bool initialized_; |
114 | 125 |
115 base::Time last_used_; | 126 base::Time last_used_; |
116 base::Time last_modified_; | 127 base::Time last_modified_; |
117 int32 data_size_[kSimpleEntryFileCount]; | 128 int32 data_size_[kSimpleEntryFileCount]; |
118 | 129 |
119 base::PlatformFile files_[kSimpleEntryFileCount]; | 130 base::PlatformFile files_[kSimpleEntryFileCount]; |
120 }; | 131 }; |
121 | 132 |
122 } // namespace disk_cache | 133 } // namespace disk_cache |
123 | 134 |
124 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ | 135 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ |
OLD | NEW |