| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BLOCKFILE_SPARSE_CONTROL_V3_H_ | 5 #ifndef NET_DISK_CACHE_BLOCKFILE_SPARSE_CONTROL_V3_H_ |
| 6 #define NET_DISK_CACHE_BLOCKFILE_SPARSE_CONTROL_V3_H_ | 6 #define NET_DISK_CACHE_BLOCKFILE_SPARSE_CONTROL_V3_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // Performs a quick test to see if the entry is sparse or not, without | 47 // Performs a quick test to see if the entry is sparse or not, without |
| 48 // generating disk IO (so the answer provided is only a best effort). | 48 // generating disk IO (so the answer provided is only a best effort). |
| 49 bool CouldBeSparse() const; | 49 bool CouldBeSparse() const; |
| 50 | 50 |
| 51 // Performs an actual sparse read or write operation for this entry. |op| is | 51 // Performs an actual sparse read or write operation for this entry. |op| is |
| 52 // the operation to perform, |offset| is the desired sparse offset, |buf| and | 52 // the operation to perform, |offset| is the desired sparse offset, |buf| and |
| 53 // |buf_len| specify the actual data to use and |callback| is the callback | 53 // |buf_len| specify the actual data to use and |callback| is the callback |
| 54 // to use for asynchronous operations. See the description of the Read / | 54 // to use for asynchronous operations. See the description of the Read / |
| 55 // WriteSparseData for details about the arguments. The return value is the | 55 // WriteSparseData for details about the arguments. The return value is the |
| 56 // number of bytes read or written, or a net error code. | 56 // number of bytes read or written, or a net error code. |
| 57 int StartIO(SparseOperation op, int64 offset, net::IOBuffer* buf, | 57 int StartIO(SparseOperation op, |
| 58 int buf_len, const CompletionCallback& callback); | 58 int64 offset, |
| 59 net::IOBuffer* buf, |
| 60 int buf_len, |
| 61 const CompletionCallback& callback); |
| 59 | 62 |
| 60 // Implements Entry::GetAvailableRange(). | 63 // Implements Entry::GetAvailableRange(). |
| 61 int GetAvailableRange(int64 offset, int len, int64* start); | 64 int GetAvailableRange(int64 offset, int len, int64* start); |
| 62 | 65 |
| 63 // Cancels the current sparse operation (if any). | 66 // Cancels the current sparse operation (if any). |
| 64 void CancelIO(); | 67 void CancelIO(); |
| 65 | 68 |
| 66 // Returns OK if the entry can be used for new IO or ERR_IO_PENDING if we are | 69 // Returns OK if the entry can be used for new IO or ERR_IO_PENDING if we are |
| 67 // busy. If the entry is busy, we'll invoke the callback when we are ready | 70 // busy. If the entry is busy, we'll invoke the callback when we are ready |
| 68 // again. See disk_cache::Entry::ReadyToUse() for more info. | 71 // again. See disk_cache::Entry::ReadyToUse() for more info. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 86 | 89 |
| 87 // Opens and closes a child entry. A child entry is a regular EntryImpl object | 90 // Opens and closes a child entry. A child entry is a regular EntryImpl object |
| 88 // with a key derived from the key of the resource to store and the range | 91 // with a key derived from the key of the resource to store and the range |
| 89 // stored by that child. | 92 // stored by that child. |
| 90 bool OpenChild(); | 93 bool OpenChild(); |
| 91 void CloseChild(); | 94 void CloseChild(); |
| 92 | 95 |
| 93 // Continues the current operation (open) without a current child. | 96 // Continues the current operation (open) without a current child. |
| 94 bool ContinueWithoutChild(const std::string& key); | 97 bool ContinueWithoutChild(const std::string& key); |
| 95 | 98 |
| 96 // Writes to disk the tracking information for this entry. | 99 // Writes to disk the tracking information for this entry. |
| 97 void WriteSparseData(); | 100 void WriteSparseData(); |
| 98 | 101 |
| 99 // Performs a single operation with the current child. Returns true when we | 102 // Performs a single operation with the current child. Returns true when we |
| 100 // should move on to the next child and false when we should interrupt our | 103 // should move on to the next child and false when we should interrupt our |
| 101 // work. | 104 // work. |
| 102 bool DoChildIO(); | 105 bool DoChildIO(); |
| 103 | 106 |
| 104 // Performs the required work after a single IO operations finishes. | 107 // Performs the required work after a single IO operations finishes. |
| 105 void DoChildIOCompleted(int result); | 108 void DoChildIOCompleted(int result); |
| 106 | 109 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // Invoked by the callback of asynchronous operations. | 147 // Invoked by the callback of asynchronous operations. |
| 145 void OnChildIOCompleted(int result); | 148 void OnChildIOCompleted(int result); |
| 146 | 149 |
| 147 EntryImpl* entry_; // The sparse entry. | 150 EntryImpl* entry_; // The sparse entry. |
| 148 EntryImpl* child_; // The current child entry. | 151 EntryImpl* child_; // The current child entry. |
| 149 SparseOperation operation_; | 152 SparseOperation operation_; |
| 150 bool pending_; // True if any child IO operation returned pending. | 153 bool pending_; // True if any child IO operation returned pending. |
| 151 bool finished_; | 154 bool finished_; |
| 152 bool init_; | 155 bool init_; |
| 153 bool range_found_; // True if GetAvailableRange found something. | 156 bool range_found_; // True if GetAvailableRange found something. |
| 154 bool abort_; // True if we should abort the current operation ASAP. | 157 bool abort_; // True if we should abort the current operation ASAP. |
| 155 | 158 |
| 156 SparseHeader sparse_header_; // Data about the children of entry_. | 159 SparseHeader sparse_header_; // Data about the children of entry_. |
| 157 Bitmap children_map_; // The actual bitmap of children. | 160 Bitmap children_map_; // The actual bitmap of children. |
| 158 SparseData child_data_; // Parent and allocation map of child_. | 161 SparseData child_data_; // Parent and allocation map of child_. |
| 159 Bitmap child_map_; // The allocation map as a bitmap. | 162 Bitmap child_map_; // The allocation map as a bitmap. |
| 160 | 163 |
| 161 CompletionCallback user_callback_; | 164 CompletionCallback user_callback_; |
| 162 std::vector<CompletionCallback> abort_callbacks_; | 165 std::vector<CompletionCallback> abort_callbacks_; |
| 163 int64 offset_; // Current sparse offset. | 166 int64 offset_; // Current sparse offset. |
| 164 scoped_refptr<net::DrainableIOBuffer> user_buf_; | 167 scoped_refptr<net::DrainableIOBuffer> user_buf_; |
| 165 int buf_len_; // Bytes to read or write. | 168 int buf_len_; // Bytes to read or write. |
| 166 int child_offset_; // Offset to use for the current child. | 169 int child_offset_; // Offset to use for the current child. |
| 167 int child_len_; // Bytes to read or write for this child. | 170 int child_len_; // Bytes to read or write for this child. |
| 168 int result_; | 171 int result_; |
| 169 | 172 |
| 170 DISALLOW_COPY_AND_ASSIGN(SparseControl); | 173 DISALLOW_COPY_AND_ASSIGN(SparseControl); |
| 171 }; | 174 }; |
| 172 | 175 |
| 173 } // namespace disk_cache | 176 } // namespace disk_cache |
| 174 | 177 |
| 175 #endif // NET_DISK_CACHE_BLOCKFILE_SPARSE_CONTROL_V3_H_ | 178 #endif // NET_DISK_CACHE_BLOCKFILE_SPARSE_CONTROL_V3_H_ |
| OLD | NEW |