Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(598)

Side by Side Diff: net/disk_cache/simple/simple_entry_impl.h

Issue 22859060: Fix race condition for non-open/create operations happening after a doom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/entry_unittest.cc ('k') | net/disk_cache/simple/simple_entry_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 int buf_len, 172 int buf_len,
173 const CompletionCallback& callback); 173 const CompletionCallback& callback);
174 174
175 void WriteDataInternal(int index, 175 void WriteDataInternal(int index,
176 int offset, 176 int offset,
177 net::IOBuffer* buf, 177 net::IOBuffer* buf,
178 int buf_len, 178 int buf_len,
179 const CompletionCallback& callback, 179 const CompletionCallback& callback,
180 bool truncate); 180 bool truncate);
181 181
182 void DoomEntryInternal(const CompletionCallback& callback);
183
182 // Called after a SimpleSynchronousEntry has completed CreateEntry() or 184 // Called after a SimpleSynchronousEntry has completed CreateEntry() or
183 // OpenEntry(). If |in_sync_entry| is non-NULL, creation is successful and we 185 // OpenEntry(). If |in_sync_entry| is non-NULL, creation is successful and we
184 // can return |this| SimpleEntryImpl to |*out_entry|. Runs 186 // can return |this| SimpleEntryImpl to |*out_entry|. Runs
185 // |completion_callback|. 187 // |completion_callback|.
186 void CreationOperationComplete( 188 void CreationOperationComplete(
187 const CompletionCallback& completion_callback, 189 const CompletionCallback& completion_callback,
188 const base::TimeTicks& start_time, 190 const base::TimeTicks& start_time,
189 scoped_ptr<SimpleEntryCreationResults> in_results, 191 scoped_ptr<SimpleEntryCreationResults> in_results,
190 Entry** out_entry, 192 Entry** out_entry,
191 net::NetLog::EventType end_event_type); 193 net::NetLog::EventType end_event_type);
(...skipping 17 matching lines...) Expand all
209 scoped_ptr<uint32> read_crc32, 211 scoped_ptr<uint32> read_crc32,
210 scoped_ptr<base::Time> last_used, 212 scoped_ptr<base::Time> last_used,
211 scoped_ptr<int> result); 213 scoped_ptr<int> result);
212 214
213 // Called after an asynchronous write completes. 215 // Called after an asynchronous write completes.
214 void WriteOperationComplete(int stream_index, 216 void WriteOperationComplete(int stream_index,
215 const CompletionCallback& completion_callback, 217 const CompletionCallback& completion_callback,
216 scoped_ptr<SimpleEntryStat> entry_stat, 218 scoped_ptr<SimpleEntryStat> entry_stat,
217 scoped_ptr<int> result); 219 scoped_ptr<int> result);
218 220
221 // Called after an asynchronous doom completes.
222 void DoomOperationComplete(const CompletionCallback& callback,
223 State state_to_restore,
224 int result);
225
219 // Called after validating the checksums on an entry. Passes through the 226 // Called after validating the checksums on an entry. Passes through the
220 // original result if successful, propogates the error if the checksum does 227 // original result if successful, propogates the error if the checksum does
221 // not validate. 228 // not validate.
222 void ChecksumOperationComplete( 229 void ChecksumOperationComplete(
223 int stream_index, 230 int stream_index,
224 int orig_result, 231 int orig_result,
225 const CompletionCallback& completion_callback, 232 const CompletionCallback& completion_callback,
226 scoped_ptr<int> result); 233 scoped_ptr<int> result);
227 234
228 // Called after completion of asynchronous IO and receiving file metadata for 235 // Called after completion of asynchronous IO and receiving file metadata for
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 uint32 crc32s_[kSimpleEntryFileCount]; 277 uint32 crc32s_[kSimpleEntryFileCount];
271 278
272 // If |have_written_[index]| is true, we have written to the stream |index|. 279 // If |have_written_[index]| is true, we have written to the stream |index|.
273 bool have_written_[kSimpleEntryFileCount]; 280 bool have_written_[kSimpleEntryFileCount];
274 281
275 // Reflects how much CRC checking has been done with the entry. This state is 282 // Reflects how much CRC checking has been done with the entry. This state is
276 // reported on closing each entry stream. 283 // reported on closing each entry stream.
277 CheckCrcResult crc_check_state_[kSimpleEntryFileCount]; 284 CheckCrcResult crc_check_state_[kSimpleEntryFileCount];
278 285
279 // The |synchronous_entry_| is the worker thread object that performs IO on 286 // The |synchronous_entry_| is the worker thread object that performs IO on
280 // entries. It's owned by this SimpleEntryImpl whenever |operation_running_| 287 // entries. It's owned by this SimpleEntryImpl whenever |executing_operation_|
281 // is false (i.e. when an operation is not pending on the worker pool). 288 // is false (i.e. when an operation is not pending on the worker pool). When
289 // an operation is being executed no one owns the synchronous entry. Therefore
290 // SimpleEntryImpl should not be deleted while an operation is running as that
291 // would leak the SimpleSynchronousEntry.
282 SimpleSynchronousEntry* synchronous_entry_; 292 SimpleSynchronousEntry* synchronous_entry_;
283 293
284 std::queue<SimpleEntryOperation> pending_operations_; 294 std::queue<SimpleEntryOperation> pending_operations_;
285 295
286 net::BoundNetLog net_log_; 296 net::BoundNetLog net_log_;
287 297
288 scoped_ptr<SimpleEntryOperation> executing_operation_; 298 scoped_ptr<SimpleEntryOperation> executing_operation_;
289 }; 299 };
290 300
291 } // namespace disk_cache 301 } // namespace disk_cache
292 302
293 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ 303 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_
OLDNEW
« no previous file with comments | « net/disk_cache/entry_unittest.cc ('k') | net/disk_cache/simple/simple_entry_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698