Chromium Code Reviews| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 // has been assigned. This is the state at construction, and is the only | 97 // has been assigned. This is the state at construction, and is the only |
| 98 // legal state to destruct an entry in. | 98 // legal state to destruct an entry in. |
| 99 STATE_UNINITIALIZED, | 99 STATE_UNINITIALIZED, |
| 100 | 100 |
| 101 // This entry is available for regular IO. | 101 // This entry is available for regular IO. |
| 102 STATE_READY, | 102 STATE_READY, |
| 103 | 103 |
| 104 // IO is currently in flight, operations must wait for completion before | 104 // IO is currently in flight, operations must wait for completion before |
| 105 // launching. | 105 // launching. |
| 106 STATE_IO_PENDING, | 106 STATE_IO_PENDING, |
| 107 | |
| 108 // A failure occurred in the current or previous operation. All operations | |
| 109 // after that must fail too. | |
| 110 STATE_FAILURE, | |
| 107 }; | 111 }; |
| 108 | 112 |
| 109 virtual ~SimpleEntryImpl(); | 113 virtual ~SimpleEntryImpl(); |
| 110 | 114 |
| 111 // Sets entry o STATE_UNINITIALIZED. | 115 // Sets entry o STATE_UNINITIALIZED. |
| 112 void MakeUninitialized(); | 116 void MakeUninitialized(); |
| 113 | 117 |
| 114 // Return this entry to a user of the API in |out_entry|. Increments the user | 118 // Return this entry to a user of the API in |out_entry|. Increments the user |
| 115 // count. | 119 // count. |
| 116 void ReturnEntryToCaller(Entry** out_entry); | 120 void ReturnEntryToCaller(Entry** out_entry); |
| 117 | 121 |
| 118 // Ensures that |this| is no longer referenced by our |backend_|, this | 122 // Ensures that |this| is no longer referenced by our |backend_|, this |
| 119 // guarantees that this entry cannot have OpenEntry/CreateEntry called again. | 123 // guarantees that this entry cannot have OpenEntry/CreateEntry called again. |
| 120 void RemoveSelfFromBackend(); | 124 void RemoveSelfFromBackend(); |
| 121 | 125 |
| 122 // An error occured, and the SimpleSynchronousEntry should have Doomed | 126 // An error occured, and the SimpleSynchronousEntry should have Doomed |
| 123 // us at this point. We need to remove |this| from the Backend and the | 127 // us at this point. We need to remove |this| from the Backend and the |
| 124 // index. | 128 // index. |
| 125 void MarkAsDoomed(); | 129 void MarkAsDoomed(); |
| 126 | 130 |
| 127 // Runs the next operation in the queue, if any and if there is no other | 131 // Runs the next operation in the queue, if any and if there is no other |
| 128 // operation running at the moment. | 132 // operation running at the moment. |
| 129 // WARNING: May delete |this|, as an operation in the queue can contain | 133 // WARNING: May delete |this|, as an operation in the queue can contain |
| 130 // the last reference. | 134 // the last reference. |
| 131 void RunNextOperationIfNeeded(); | 135 void RunNextOperationIfNeeded(); |
| 132 | 136 |
| 133 void OpenEntryInternal(Entry** entry, | 137 void OpenEntryInternal(const CompletionCallback& callback, Entry** out_entry); |
| 134 const CompletionCallback& callback); | |
| 135 | 138 |
| 136 void CreateEntryInternal(Entry** entry, | 139 void CreateEntryInternal(const CompletionCallback& callback, |
| 137 const CompletionCallback& callback); | 140 Entry** out_entry); |
| 138 | 141 |
| 139 void CloseInternal(); | 142 void CloseInternal(); |
| 140 | 143 |
| 141 void ReadDataInternal(int index, | 144 void ReadDataInternal(int index, |
| 142 int offset, | 145 int offset, |
| 143 net::IOBuffer* buf, | 146 net::IOBuffer* buf, |
| 144 int buf_len, | 147 int buf_len, |
| 145 const CompletionCallback& callback); | 148 const CompletionCallback& callback); |
| 146 | 149 |
| 147 void WriteDataInternal(int index, | 150 void WriteDataInternal(int index, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 | 230 |
| 228 // If |have_written_[index]| is true, we have written to the stream |index|. | 231 // If |have_written_[index]| is true, we have written to the stream |index|. |
| 229 bool have_written_[kSimpleEntryFileCount]; | 232 bool have_written_[kSimpleEntryFileCount]; |
| 230 | 233 |
| 231 // The |synchronous_entry_| is the worker thread object that performs IO on | 234 // The |synchronous_entry_| is the worker thread object that performs IO on |
| 232 // entries. It's owned by this SimpleEntryImpl whenever |operation_running_| | 235 // entries. It's owned by this SimpleEntryImpl whenever |operation_running_| |
| 233 // is false (i.e. when an operation is not pending on the worker pool). | 236 // is false (i.e. when an operation is not pending on the worker pool). |
| 234 SimpleSynchronousEntry* synchronous_entry_; | 237 SimpleSynchronousEntry* synchronous_entry_; |
| 235 | 238 |
| 236 std::queue<base::Closure> pending_operations_; | 239 std::queue<base::Closure> pending_operations_; |
| 240 | |
| 241 // Flag to turn On or Off Create and Write optimistic operations. | |
| 242 bool optimistic_; | |
|
gavinp
2013/05/01 13:11:22
I think we should either test with this flag (sinc
felipeg
2013/05/02 09:49:27
I will remove it and we add it later if we need it
| |
| 237 }; | 243 }; |
| 238 | 244 |
| 239 } // namespace disk_cache | 245 } // namespace disk_cache |
| 240 | 246 |
| 241 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ | 247 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ |
| OLD | NEW |