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

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: Only make doom operations use the pending operations queue 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
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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 int buf_len, 170 int buf_len,
171 const CompletionCallback& callback); 171 const CompletionCallback& callback);
172 172
173 void WriteDataInternal(int index, 173 void WriteDataInternal(int index,
174 int offset, 174 int offset,
175 net::IOBuffer* buf, 175 net::IOBuffer* buf,
176 int buf_len, 176 int buf_len,
177 const CompletionCallback& callback, 177 const CompletionCallback& callback,
178 bool truncate); 178 bool truncate);
179 179
180 void DoomEntryInternal(const CompletionCallback& callback);
181
180 // Called after a SimpleSynchronousEntry has completed CreateEntry() or 182 // Called after a SimpleSynchronousEntry has completed CreateEntry() or
181 // OpenEntry(). If |in_sync_entry| is non-NULL, creation is successful and we 183 // OpenEntry(). If |in_sync_entry| is non-NULL, creation is successful and we
182 // can return |this| SimpleEntryImpl to |*out_entry|. Runs 184 // can return |this| SimpleEntryImpl to |*out_entry|. Runs
183 // |completion_callback|. 185 // |completion_callback|.
184 void CreationOperationComplete( 186 void CreationOperationComplete(
185 const CompletionCallback& completion_callback, 187 const CompletionCallback& completion_callback,
186 const base::TimeTicks& start_time, 188 const base::TimeTicks& start_time,
187 scoped_ptr<SimpleEntryCreationResults> in_results, 189 scoped_ptr<SimpleEntryCreationResults> in_results,
188 Entry** out_entry, 190 Entry** out_entry,
189 net::NetLog::EventType end_event_type); 191 net::NetLog::EventType end_event_type);
(...skipping 17 matching lines...) Expand all
207 scoped_ptr<uint32> read_crc32, 209 scoped_ptr<uint32> read_crc32,
208 scoped_ptr<base::Time> last_used, 210 scoped_ptr<base::Time> last_used,
209 scoped_ptr<int> result); 211 scoped_ptr<int> result);
210 212
211 // Called after an asynchronous write completes. 213 // Called after an asynchronous write completes.
212 void WriteOperationComplete(int stream_index, 214 void WriteOperationComplete(int stream_index,
213 const CompletionCallback& completion_callback, 215 const CompletionCallback& completion_callback,
214 scoped_ptr<SimpleEntryStat> entry_stat, 216 scoped_ptr<SimpleEntryStat> entry_stat,
215 scoped_ptr<int> result); 217 scoped_ptr<int> result);
216 218
219 // Called after an asynchronous doom completes.
220 void DoomOperationComplete(const CompletionCallback& callback,
221 State state_to_restore,
222 int result);
223
217 // Called after validating the checksums on an entry. Passes through the 224 // Called after validating the checksums on an entry. Passes through the
218 // original result if successful, propogates the error if the checksum does 225 // original result if successful, propogates the error if the checksum does
219 // not validate. 226 // not validate.
220 void ChecksumOperationComplete( 227 void ChecksumOperationComplete(
221 int stream_index, 228 int stream_index,
222 int orig_result, 229 int orig_result,
223 const CompletionCallback& completion_callback, 230 const CompletionCallback& completion_callback,
224 scoped_ptr<int> result); 231 scoped_ptr<int> result);
225 232
226 // Called after completion of asynchronous IO and receiving file metadata for 233 // Called after completion of asynchronous IO and receiving file metadata for
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 uint32 crc32s_[kSimpleEntryFileCount]; 274 uint32 crc32s_[kSimpleEntryFileCount];
268 275
269 // If |have_written_[index]| is true, we have written to the stream |index|. 276 // If |have_written_[index]| is true, we have written to the stream |index|.
270 bool have_written_[kSimpleEntryFileCount]; 277 bool have_written_[kSimpleEntryFileCount];
271 278
272 // Reflects how much CRC checking has been done with the entry. This state is 279 // Reflects how much CRC checking has been done with the entry. This state is
273 // reported on closing each entry stream. 280 // reported on closing each entry stream.
274 CheckCrcResult crc_check_state_[kSimpleEntryFileCount]; 281 CheckCrcResult crc_check_state_[kSimpleEntryFileCount];
275 282
276 // The |synchronous_entry_| is the worker thread object that performs IO on 283 // The |synchronous_entry_| is the worker thread object that performs IO on
277 // entries. It's owned by this SimpleEntryImpl whenever |operation_running_| 284 // entries. It's owned by this SimpleEntryImpl whenever |executing_operation_|
278 // is false (i.e. when an operation is not pending on the worker pool). 285 // is false (i.e. when an operation is not pending on the worker pool).
Randy Smith (Not in Mondays) 2013/09/03 18:48:19 Suggestion (doesn't have to be part of this CL, ju
Philippe 2013/09/04 09:35:23 Thanks.
279 SimpleSynchronousEntry* synchronous_entry_; 286 SimpleSynchronousEntry* synchronous_entry_;
280 287
281 std::queue<SimpleEntryOperation> pending_operations_; 288 std::queue<SimpleEntryOperation> pending_operations_;
282 289
283 net::BoundNetLog net_log_; 290 net::BoundNetLog net_log_;
284 291
285 scoped_ptr<SimpleEntryOperation> executing_operation_; 292 scoped_ptr<SimpleEntryOperation> executing_operation_;
286 }; 293 };
287 294
288 } // namespace disk_cache 295 } // namespace disk_cache
289 296
290 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ 297 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698