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

Side by Side Diff: net/disk_cache/sparse_control.h

Issue 146005: Disk Cache: Implement GetAvailableRange for the regular disk cache.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 6 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_SPARSE_CONTROL_H_ 5 #ifndef NET_DISK_CACHE_SPARSE_CONTROL_H_
6 #define NET_DISK_CACHE_SPARSE_CONTROL_H_ 6 #define NET_DISK_CACHE_SPARSE_CONTROL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 16 matching lines...) Expand all
27 // Basically, sparse IO is directed from EntryImpl to this class, and we split 27 // Basically, sparse IO is directed from EntryImpl to this class, and we split
28 // the operation into multiple small pieces, sending each one to the 28 // the operation into multiple small pieces, sending each one to the
29 // appropriate entry. An instance of this class is asociated with each entry 29 // appropriate entry. An instance of this class is asociated with each entry
30 // used directly for sparse operations (the entry passed in to the constructor). 30 // used directly for sparse operations (the entry passed in to the constructor).
31 class SparseControl { 31 class SparseControl {
32 public: 32 public:
33 // The operation to perform. 33 // The operation to perform.
34 enum SparseOperation { 34 enum SparseOperation {
35 kNoOperation, 35 kNoOperation,
36 kReadOperation, 36 kReadOperation,
37 kWriteOperation 37 kWriteOperation,
38 kGetRangeOperation
38 }; 39 };
39 40
40 explicit SparseControl(EntryImpl* entry) 41 explicit SparseControl(EntryImpl* entry)
41 : entry_(entry), child_(NULL), operation_(kNoOperation), init_(false), 42 : entry_(entry), child_(NULL), operation_(kNoOperation), init_(false),
42 child_map_(child_data_.bitmap, kNumSparseBits, kNumSparseBits / 32), 43 child_map_(child_data_.bitmap, kNumSparseBits, kNumSparseBits / 32),
43 ALLOW_THIS_IN_INITIALIZER_LIST( 44 ALLOW_THIS_IN_INITIALIZER_LIST(
44 child_callback_(this, &SparseControl::OnChildIOCompleted)), 45 child_callback_(this, &SparseControl::OnChildIOCompleted)),
45 user_callback_(NULL) {} 46 user_callback_(NULL) {}
46 ~SparseControl(); 47 ~SparseControl();
47 48
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 void InitChildData(); 103 void InitChildData();
103 104
104 // Iterates through all the children needed to complete the current operation. 105 // Iterates through all the children needed to complete the current operation.
105 void DoChildrenIO(); 106 void DoChildrenIO();
106 107
107 // Performs a single operation with the current child. Returns true when we 108 // Performs a single operation with the current child. Returns true when we
108 // should move on to the next child and false when we should interrupt our 109 // should move on to the next child and false when we should interrupt our
109 // work. 110 // work.
110 bool DoChildIO(); 111 bool DoChildIO();
111 112
113 // Performs the required work for GetAvailableRange for one child.
114 int DoGetAvailableRange();
115
112 // Performs the required work after a single IO operations finishes. 116 // Performs the required work after a single IO operations finishes.
113 void DoChildIOCompleted(int result); 117 void DoChildIOCompleted(int result);
114 118
115 // Invoked by the callback of asynchronous operations. 119 // Invoked by the callback of asynchronous operations.
116 void OnChildIOCompleted(int result); 120 void OnChildIOCompleted(int result);
117 121
118 // Reports to the user that we are done. 122 // Reports to the user that we are done.
119 void DoUserCallback(); 123 void DoUserCallback();
120 124
121 EntryImpl* entry_; // The sparse entry. 125 EntryImpl* entry_; // The sparse entry.
122 Entry* child_; // The current child entry. 126 Entry* child_; // The current child entry.
123 SparseOperation operation_; 127 SparseOperation operation_;
124 bool pending_; // True if any child IO operation returned pending. 128 bool pending_; // True if any child IO operation returned pending.
125 bool finished_; 129 bool finished_;
126 bool init_; 130 bool init_;
131 bool range_found_; // True if GetAvailableRange found something.
127 132
128 SparseHeader sparse_header_; // Data about the children of entry_. 133 SparseHeader sparse_header_; // Data about the children of entry_.
129 Bitmap children_map_; // The actual bitmap of children. 134 Bitmap children_map_; // The actual bitmap of children.
130 SparseData child_data_; // Parent and allocation map of child_. 135 SparseData child_data_; // Parent and allocation map of child_.
131 Bitmap child_map_; // The allocation map as a bitmap. 136 Bitmap child_map_; // The allocation map as a bitmap.
132 137
133 net::CompletionCallbackImpl<SparseControl> child_callback_; 138 net::CompletionCallbackImpl<SparseControl> child_callback_;
134 net::CompletionCallback* user_callback_; 139 net::CompletionCallback* user_callback_;
135 int64 offset_; // Current sparse offset. 140 int64 offset_; // Current sparse offset.
136 scoped_refptr<net::ReusedIOBuffer> user_buf_; 141 scoped_refptr<net::ReusedIOBuffer> user_buf_;
137 int buf_len_; // Bytes to read or write. 142 int buf_len_; // Bytes to read or write.
138 int child_offset_; // Offset to use for the current child. 143 int child_offset_; // Offset to use for the current child.
139 int child_len_; // Bytes to read or write for this child. 144 int child_len_; // Bytes to read or write for this child.
140 int result_; 145 int result_;
141 146
142 DISALLOW_COPY_AND_ASSIGN(SparseControl); 147 DISALLOW_COPY_AND_ASSIGN(SparseControl);
143 }; 148 };
144 149
145 } // namespace disk_cache 150 } // namespace disk_cache
146 151
147 #endif // NET_DISK_CACHE_SPARSE_CONTROL_H_ 152 #endif // NET_DISK_CACHE_SPARSE_CONTROL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698