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_ENTRY_IMPL_H_ | 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ |
6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ | 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 const base::FilePath& path, | 76 const base::FilePath& path, |
77 uint64_t entry_hash, | 77 uint64_t entry_hash, |
78 OperationsMode operations_mode, | 78 OperationsMode operations_mode, |
79 SimpleBackendImpl* backend, | 79 SimpleBackendImpl* backend, |
80 net::NetLog* net_log); | 80 net::NetLog* net_log); |
81 | 81 |
82 void SetActiveEntryProxy( | 82 void SetActiveEntryProxy( |
83 std::unique_ptr<ActiveEntryProxy> active_entry_proxy); | 83 std::unique_ptr<ActiveEntryProxy> active_entry_proxy); |
84 | 84 |
85 // Adds another reader/writer to this entry, if possible, returning |this| to | 85 // Adds another reader/writer to this entry, if possible, returning |this| to |
86 // |entry|. | 86 // |entry|. |oracle| is permitted to be a null callback. |
87 int OpenEntry(Entry** entry, const CompletionCallback& callback); | 87 int OpenEntry(Entry** entry, |
| 88 const Backend::OracleCallback& oracle, |
| 89 const CompletionCallback& callback); |
88 | 90 |
89 // Creates this entry, if possible. Returns |this| to |entry|. | 91 // Creates this entry, if possible. Returns |this| to |entry|. |
90 int CreateEntry(Entry** entry, const CompletionCallback& callback); | 92 int CreateEntry(Entry** entry, const CompletionCallback& callback); |
91 | 93 |
92 // Identical to Backend::Doom() except that it accepts a CompletionCallback. | 94 // Identical to Backend::Doom() except that it accepts a CompletionCallback. |
93 int DoomEntry(const CompletionCallback& callback); | 95 int DoomEntry(const CompletionCallback& callback); |
94 | 96 |
95 const std::string& key() const { return key_; } | 97 const std::string& key() const { return key_; } |
96 uint64_t entry_hash() const { return entry_hash_; } | 98 uint64_t entry_hash() const { return entry_hash_; } |
97 | 99 |
98 // The key is not a constructor parameter to the SimpleEntryImpl, because | 100 // The key is not a constructor parameter to the SimpleEntryImpl, because |
99 // during cache iteration, it's necessary to open entries by their hash | 101 // during cache iteration, it's necessary to open entries by their hash |
100 // alone. In that case, the SimpleSynchronousEntry will read the key from disk | 102 // alone. In that case, the SimpleSynchronousEntry will read the key from disk |
101 // and it will be set. | 103 // and it will be set. |
102 void SetKey(const std::string& key); | 104 void SetKey(const std::string& key); |
103 | 105 |
104 // From Entry: | 106 // From Entry: |
105 void Doom() override; | 107 void Doom() override; |
106 void Close() override; | 108 void Close() override; |
107 std::string GetKey() const override; | 109 std::string GetKey() const override; |
108 base::Time GetLastUsed() const override; | 110 base::Time GetLastUsed() const override; |
109 base::Time GetLastModified() const override; | 111 base::Time GetLastModified() const override; |
110 int32_t GetDataSize(int index) const override; | 112 int32_t GetDataSize(int index) const override; |
| 113 void SetOracleByte(uint8_t) override; |
111 int ReadData(int stream_index, | 114 int ReadData(int stream_index, |
112 int offset, | 115 int offset, |
113 net::IOBuffer* buf, | 116 net::IOBuffer* buf, |
114 int buf_len, | 117 int buf_len, |
115 const CompletionCallback& callback) override; | 118 const CompletionCallback& callback) override; |
116 int WriteData(int stream_index, | 119 int WriteData(int stream_index, |
117 int offset, | 120 int offset, |
118 net::IOBuffer* buf, | 121 net::IOBuffer* buf, |
119 int buf_len, | 122 int buf_len, |
120 const CompletionCallback& callback, | 123 const CompletionCallback& callback, |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 // 1 on disk, to reduce the number of file descriptors and save disk space. | 404 // 1 on disk, to reduce the number of file descriptors and save disk space. |
402 // This strategy allows stream 1 to change size easily. Since stream 0 is only | 405 // This strategy allows stream 1 to change size easily. Since stream 0 is only |
403 // used to write HTTP headers, the memory consumption of keeping it in memory | 406 // used to write HTTP headers, the memory consumption of keeping it in memory |
404 // is acceptable. | 407 // is acceptable. |
405 scoped_refptr<net::GrowableIOBuffer> stream_0_data_; | 408 scoped_refptr<net::GrowableIOBuffer> stream_0_data_; |
406 }; | 409 }; |
407 | 410 |
408 } // namespace disk_cache | 411 } // namespace disk_cache |
409 | 412 |
410 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ | 413 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ |
OLD | NEW |