| 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 <stdint.h> |
| 9 |
| 8 #include <string> | 10 #include <string> |
| 9 #include <vector> | 11 #include <vector> |
| 10 | 12 |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/macros.h" |
| 13 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
| 14 #include "net/disk_cache/blockfile/bitmap.h" | 16 #include "net/disk_cache/blockfile/bitmap.h" |
| 15 #include "net/disk_cache/disk_format.h" | 17 #include "net/disk_cache/disk_format.h" |
| 16 | 18 |
| 17 namespace net { | 19 namespace net { |
| 18 class IOBuffer; | 20 class IOBuffer; |
| 19 class DrainableIOBuffer; | 21 class DrainableIOBuffer; |
| 20 } | 22 } |
| 21 | 23 |
| 22 namespace disk_cache { | 24 namespace disk_cache { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 47 // Performs a quick test to see if the entry is sparse or not, without | 49 // 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). | 50 // generating disk IO (so the answer provided is only a best effort). |
| 49 bool CouldBeSparse() const; | 51 bool CouldBeSparse() const; |
| 50 | 52 |
| 51 // Performs an actual sparse read or write operation for this entry. |op| is | 53 // 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 | 54 // 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 | 55 // |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 / | 56 // to use for asynchronous operations. See the description of the Read / |
| 55 // WriteSparseData for details about the arguments. The return value is the | 57 // WriteSparseData for details about the arguments. The return value is the |
| 56 // number of bytes read or written, or a net error code. | 58 // number of bytes read or written, or a net error code. |
| 57 int StartIO(SparseOperation op, int64 offset, net::IOBuffer* buf, | 59 int StartIO(SparseOperation op, |
| 58 int buf_len, const CompletionCallback& callback); | 60 int64_t offset, |
| 61 net::IOBuffer* buf, |
| 62 int buf_len, |
| 63 const CompletionCallback& callback); |
| 59 | 64 |
| 60 // Implements Entry::GetAvailableRange(). | 65 // Implements Entry::GetAvailableRange(). |
| 61 int GetAvailableRange(int64 offset, int len, int64* start); | 66 int GetAvailableRange(int64_t offset, int len, int64_t* start); |
| 62 | 67 |
| 63 // Cancels the current sparse operation (if any). | 68 // Cancels the current sparse operation (if any). |
| 64 void CancelIO(); | 69 void CancelIO(); |
| 65 | 70 |
| 66 // Returns OK if the entry can be used for new IO or ERR_IO_PENDING if we are | 71 // 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 | 72 // 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. | 73 // again. See disk_cache::Entry::ReadyToUse() for more info. |
| 69 int ReadyToUse(const CompletionCallback& completion_callback); | 74 int ReadyToUse(const CompletionCallback& completion_callback); |
| 70 | 75 |
| 71 // Deletes the children entries of |entry|. | 76 // Deletes the children entries of |entry|. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 bool range_found_; // True if GetAvailableRange found something. | 158 bool range_found_; // True if GetAvailableRange found something. |
| 154 bool abort_; // True if we should abort the current operation ASAP. | 159 bool abort_; // True if we should abort the current operation ASAP. |
| 155 | 160 |
| 156 SparseHeader sparse_header_; // Data about the children of entry_. | 161 SparseHeader sparse_header_; // Data about the children of entry_. |
| 157 Bitmap children_map_; // The actual bitmap of children. | 162 Bitmap children_map_; // The actual bitmap of children. |
| 158 SparseData child_data_; // Parent and allocation map of child_. | 163 SparseData child_data_; // Parent and allocation map of child_. |
| 159 Bitmap child_map_; // The allocation map as a bitmap. | 164 Bitmap child_map_; // The allocation map as a bitmap. |
| 160 | 165 |
| 161 CompletionCallback user_callback_; | 166 CompletionCallback user_callback_; |
| 162 std::vector<CompletionCallback> abort_callbacks_; | 167 std::vector<CompletionCallback> abort_callbacks_; |
| 163 int64 offset_; // Current sparse offset. | 168 int64_t offset_; // Current sparse offset. |
| 164 scoped_refptr<net::DrainableIOBuffer> user_buf_; | 169 scoped_refptr<net::DrainableIOBuffer> user_buf_; |
| 165 int buf_len_; // Bytes to read or write. | 170 int buf_len_; // Bytes to read or write. |
| 166 int child_offset_; // Offset to use for the current child. | 171 int child_offset_; // Offset to use for the current child. |
| 167 int child_len_; // Bytes to read or write for this child. | 172 int child_len_; // Bytes to read or write for this child. |
| 168 int result_; | 173 int result_; |
| 169 | 174 |
| 170 DISALLOW_COPY_AND_ASSIGN(SparseControl); | 175 DISALLOW_COPY_AND_ASSIGN(SparseControl); |
| 171 }; | 176 }; |
| 172 | 177 |
| 173 } // namespace disk_cache | 178 } // namespace disk_cache |
| 174 | 179 |
| 175 #endif // NET_DISK_CACHE_BLOCKFILE_SPARSE_CONTROL_V3_H_ | 180 #endif // NET_DISK_CACHE_BLOCKFILE_SPARSE_CONTROL_V3_H_ |
| OLD | NEW |