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