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 <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 int CreateEntry(Entry** entry, const CompletionCallback& callback); | 73 int CreateEntry(Entry** entry, const CompletionCallback& callback); |
74 | 74 |
75 // Identical to Backend::Doom() except that it accepts a CompletionCallback. | 75 // Identical to Backend::Doom() except that it accepts a CompletionCallback. |
76 int DoomEntry(const CompletionCallback& callback); | 76 int DoomEntry(const CompletionCallback& callback); |
77 | 77 |
78 const std::string& key() const { return key_; } | 78 const std::string& key() const { return key_; } |
79 uint64 entry_hash() const { return entry_hash_; } | 79 uint64 entry_hash() const { return entry_hash_; } |
80 void SetKey(const std::string& key); | 80 void SetKey(const std::string& key); |
81 | 81 |
82 // From Entry: | 82 // From Entry: |
83 virtual void Doom() override; | 83 void Doom() override; |
84 virtual void Close() override; | 84 void Close() override; |
85 virtual std::string GetKey() const override; | 85 std::string GetKey() const override; |
86 virtual base::Time GetLastUsed() const override; | 86 base::Time GetLastUsed() const override; |
87 virtual base::Time GetLastModified() const override; | 87 base::Time GetLastModified() const override; |
88 virtual int32 GetDataSize(int index) const override; | 88 int32 GetDataSize(int index) const override; |
89 virtual int ReadData(int stream_index, | 89 int ReadData(int stream_index, |
90 int offset, | 90 int offset, |
91 net::IOBuffer* buf, | 91 net::IOBuffer* buf, |
92 int buf_len, | 92 int buf_len, |
93 const CompletionCallback& callback) override; | 93 const CompletionCallback& callback) override; |
94 virtual int WriteData(int stream_index, | 94 int WriteData(int stream_index, |
95 int offset, | 95 int offset, |
96 net::IOBuffer* buf, | 96 net::IOBuffer* buf, |
97 int buf_len, | 97 int buf_len, |
98 const CompletionCallback& callback, | 98 const CompletionCallback& callback, |
99 bool truncate) override; | 99 bool truncate) override; |
100 virtual int ReadSparseData(int64 offset, | 100 int ReadSparseData(int64 offset, |
101 net::IOBuffer* buf, | 101 net::IOBuffer* buf, |
102 int buf_len, | 102 int buf_len, |
103 const CompletionCallback& callback) override; | 103 const CompletionCallback& callback) override; |
104 virtual int WriteSparseData(int64 offset, | 104 int WriteSparseData(int64 offset, |
105 net::IOBuffer* buf, | 105 net::IOBuffer* buf, |
106 int buf_len, | 106 int buf_len, |
107 const CompletionCallback& callback) override; | 107 const CompletionCallback& callback) override; |
108 virtual int GetAvailableRange(int64 offset, | 108 int GetAvailableRange(int64 offset, |
109 int len, | 109 int len, |
110 int64* start, | 110 int64* start, |
111 const CompletionCallback& callback) override; | 111 const CompletionCallback& callback) override; |
112 virtual bool CouldBeSparse() const override; | 112 bool CouldBeSparse() const override; |
113 virtual void CancelSparseIO() override; | 113 void CancelSparseIO() override; |
114 virtual int ReadyForSparseIO(const CompletionCallback& callback) override; | 114 int ReadyForSparseIO(const CompletionCallback& callback) override; |
115 | 115 |
116 private: | 116 private: |
117 class ScopedOperationRunner; | 117 class ScopedOperationRunner; |
118 friend class ScopedOperationRunner; | 118 friend class ScopedOperationRunner; |
119 | 119 |
120 enum State { | 120 enum State { |
121 // The state immediately after construction, but before |synchronous_entry_| | 121 // The state immediately after construction, but before |synchronous_entry_| |
122 // has been assigned. This is the state at construction, and is the only | 122 // has been assigned. This is the state at construction, and is the only |
123 // legal state to destruct an entry in. | 123 // legal state to destruct an entry in. |
124 STATE_UNINITIALIZED, | 124 STATE_UNINITIALIZED, |
(...skipping 12 matching lines...) Expand all Loading... |
137 | 137 |
138 // Used in histograms, please only add entries at the end. | 138 // Used in histograms, please only add entries at the end. |
139 enum CheckCrcResult { | 139 enum CheckCrcResult { |
140 CRC_CHECK_NEVER_READ_TO_END = 0, | 140 CRC_CHECK_NEVER_READ_TO_END = 0, |
141 CRC_CHECK_NOT_DONE = 1, | 141 CRC_CHECK_NOT_DONE = 1, |
142 CRC_CHECK_DONE = 2, | 142 CRC_CHECK_DONE = 2, |
143 CRC_CHECK_NEVER_READ_AT_ALL = 3, | 143 CRC_CHECK_NEVER_READ_AT_ALL = 3, |
144 CRC_CHECK_MAX = 4, | 144 CRC_CHECK_MAX = 4, |
145 }; | 145 }; |
146 | 146 |
147 virtual ~SimpleEntryImpl(); | 147 ~SimpleEntryImpl() override; |
148 | 148 |
149 // Must be used to invoke a client-provided completion callback for an | 149 // Must be used to invoke a client-provided completion callback for an |
150 // operation initiated through the backend (e.g. create, open) so that clients | 150 // operation initiated through the backend (e.g. create, open) so that clients |
151 // don't get notified after they deleted the backend (which they would not | 151 // don't get notified after they deleted the backend (which they would not |
152 // expect). | 152 // expect). |
153 void PostClientCallback(const CompletionCallback& callback, int result); | 153 void PostClientCallback(const CompletionCallback& callback, int result); |
154 | 154 |
155 // Sets entry to STATE_UNINITIALIZED. | 155 // Sets entry to STATE_UNINITIALIZED. |
156 void MakeUninitialized(); | 156 void MakeUninitialized(); |
157 | 157 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 // 1 on disk, to reduce the number of file descriptors and save disk space. | 370 // 1 on disk, to reduce the number of file descriptors and save disk space. |
371 // This strategy allows stream 1 to change size easily. Since stream 0 is only | 371 // This strategy allows stream 1 to change size easily. Since stream 0 is only |
372 // used to write HTTP headers, the memory consumption of keeping it in memory | 372 // used to write HTTP headers, the memory consumption of keeping it in memory |
373 // is acceptable. | 373 // is acceptable. |
374 scoped_refptr<net::GrowableIOBuffer> stream_0_data_; | 374 scoped_refptr<net::GrowableIOBuffer> stream_0_data_; |
375 }; | 375 }; |
376 | 376 |
377 } // namespace disk_cache | 377 } // namespace disk_cache |
378 | 378 |
379 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ | 379 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ |
OLD | NEW |