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

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

Issue 13907009: Support optimistic Create and Write operations on the SimpleCache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, until we receive a Close().
110 STATE_FAILURE,
107 }; 111 };
108 112
109 virtual ~SimpleEntryImpl(); 113 virtual ~SimpleEntryImpl();
110 114
111 // Sets entry to STATE_UNINITIALIZED. 115 // Sets entry to 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // entries. It's owned by this SimpleEntryImpl whenever |operation_running_| 236 // entries. It's owned by this SimpleEntryImpl whenever |operation_running_|
234 // is false (i.e. when an operation is not pending on the worker pool). 237 // is false (i.e. when an operation is not pending on the worker pool).
235 SimpleSynchronousEntry* synchronous_entry_; 238 SimpleSynchronousEntry* synchronous_entry_;
236 239
237 std::queue<base::Closure> pending_operations_; 240 std::queue<base::Closure> pending_operations_;
238 }; 241 };
239 242
240 } // namespace disk_cache 243 } // namespace disk_cache
241 244
242 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ 245 #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