OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_OPERATION_H_ | 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_OPERATION_H_ |
6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_OPERATION_H_ | 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_OPERATION_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
9 #include "net/base/completion_callback.h" | 11 #include "net/base/completion_callback.h" |
10 #include "net/log/net_log.h" | 12 #include "net/log/net_log.h" |
11 | 13 |
12 namespace net { | 14 namespace net { |
13 class IOBuffer; | 15 class IOBuffer; |
14 } | 16 } |
15 | 17 |
16 namespace disk_cache { | 18 namespace disk_cache { |
17 | 19 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 SimpleEntryImpl* entry, | 63 SimpleEntryImpl* entry, |
62 int index, | 64 int index, |
63 int offset, | 65 int offset, |
64 int length, | 66 int length, |
65 net::IOBuffer* buf, | 67 net::IOBuffer* buf, |
66 bool truncate, | 68 bool truncate, |
67 bool optimistic, | 69 bool optimistic, |
68 const CompletionCallback& callback); | 70 const CompletionCallback& callback); |
69 static SimpleEntryOperation ReadSparseOperation( | 71 static SimpleEntryOperation ReadSparseOperation( |
70 SimpleEntryImpl* entry, | 72 SimpleEntryImpl* entry, |
71 int64 sparse_offset, | 73 int64_t sparse_offset, |
72 int length, | 74 int length, |
73 net::IOBuffer* buf, | 75 net::IOBuffer* buf, |
74 const CompletionCallback& callback); | 76 const CompletionCallback& callback); |
75 static SimpleEntryOperation WriteSparseOperation( | 77 static SimpleEntryOperation WriteSparseOperation( |
76 SimpleEntryImpl* entry, | 78 SimpleEntryImpl* entry, |
77 int64 sparse_offset, | 79 int64_t sparse_offset, |
78 int length, | 80 int length, |
79 net::IOBuffer* buf, | 81 net::IOBuffer* buf, |
80 const CompletionCallback& callback); | 82 const CompletionCallback& callback); |
81 static SimpleEntryOperation GetAvailableRangeOperation( | 83 static SimpleEntryOperation GetAvailableRangeOperation( |
82 SimpleEntryImpl* entry, | 84 SimpleEntryImpl* entry, |
83 int64 sparse_offset, | 85 int64_t sparse_offset, |
84 int length, | 86 int length, |
85 int64* out_start, | 87 int64_t* out_start, |
86 const CompletionCallback& callback); | 88 const CompletionCallback& callback); |
87 static SimpleEntryOperation DoomOperation( | 89 static SimpleEntryOperation DoomOperation( |
88 SimpleEntryImpl* entry, | 90 SimpleEntryImpl* entry, |
89 const CompletionCallback& callback); | 91 const CompletionCallback& callback); |
90 | 92 |
91 bool ConflictsWith(const SimpleEntryOperation& other_op) const; | 93 bool ConflictsWith(const SimpleEntryOperation& other_op) const; |
92 // Releases all references. After calling this operation, SimpleEntryOperation | 94 // Releases all references. After calling this operation, SimpleEntryOperation |
93 // will only hold POD members. | 95 // will only hold POD members. |
94 void ReleaseReferences(); | 96 void ReleaseReferences(); |
95 | 97 |
96 EntryOperationType type() const { | 98 EntryOperationType type() const { |
97 return static_cast<EntryOperationType>(type_); | 99 return static_cast<EntryOperationType>(type_); |
98 } | 100 } |
99 const CompletionCallback& callback() const { return callback_; } | 101 const CompletionCallback& callback() const { return callback_; } |
100 Entry** out_entry() { return out_entry_; } | 102 Entry** out_entry() { return out_entry_; } |
101 bool have_index() const { return have_index_; } | 103 bool have_index() const { return have_index_; } |
102 int index() const { return index_; } | 104 int index() const { return index_; } |
103 int offset() const { return offset_; } | 105 int offset() const { return offset_; } |
104 int64 sparse_offset() const { return sparse_offset_; } | 106 int64_t sparse_offset() const { return sparse_offset_; } |
105 int length() const { return length_; } | 107 int length() const { return length_; } |
106 int64* out_start() { return out_start_; } | 108 int64_t* out_start() { return out_start_; } |
107 net::IOBuffer* buf() { return buf_.get(); } | 109 net::IOBuffer* buf() { return buf_.get(); } |
108 bool truncate() const { return truncate_; } | 110 bool truncate() const { return truncate_; } |
109 bool optimistic() const { return optimistic_; } | 111 bool optimistic() const { return optimistic_; } |
110 bool alone_in_queue() const { return alone_in_queue_; } | 112 bool alone_in_queue() const { return alone_in_queue_; } |
111 | 113 |
112 private: | 114 private: |
113 SimpleEntryOperation(SimpleEntryImpl* entry, | 115 SimpleEntryOperation(SimpleEntryImpl* entry, |
114 net::IOBuffer* buf, | 116 net::IOBuffer* buf, |
115 const CompletionCallback& callback, | 117 const CompletionCallback& callback, |
116 Entry** out_entry, | 118 Entry** out_entry, |
117 int offset, | 119 int offset, |
118 int64 sparse_offset, | 120 int64_t sparse_offset, |
119 int length, | 121 int length, |
120 int64* out_start, | 122 int64_t* out_start, |
121 EntryOperationType type, | 123 EntryOperationType type, |
122 bool have_index, | 124 bool have_index, |
123 int index, | 125 int index, |
124 bool truncate, | 126 bool truncate, |
125 bool optimistic, | 127 bool optimistic, |
126 bool alone_in_queue); | 128 bool alone_in_queue); |
127 | 129 |
128 // This ensures entry will not be deleted until the operation has ran. | 130 // This ensures entry will not be deleted until the operation has ran. |
129 scoped_refptr<SimpleEntryImpl> entry_; | 131 scoped_refptr<SimpleEntryImpl> entry_; |
130 scoped_refptr<net::IOBuffer> buf_; | 132 scoped_refptr<net::IOBuffer> buf_; |
131 CompletionCallback callback_; | 133 CompletionCallback callback_; |
132 | 134 |
133 // Used in open and create operations. | 135 // Used in open and create operations. |
134 Entry** out_entry_; | 136 Entry** out_entry_; |
135 | 137 |
136 // Used in write and read operations. | 138 // Used in write and read operations. |
137 const int offset_; | 139 const int offset_; |
138 const int64 sparse_offset_; | 140 const int64_t sparse_offset_; |
139 const int length_; | 141 const int length_; |
140 | 142 |
141 // Used in get available range operations. | 143 // Used in get available range operations. |
142 int64* const out_start_; | 144 int64_t* const out_start_; |
143 | 145 |
144 const EntryOperationType type_; | 146 const EntryOperationType type_; |
145 // Used in open and create operations. | 147 // Used in open and create operations. |
146 const bool have_index_; | 148 const bool have_index_; |
147 // Used in write and read operations. | 149 // Used in write and read operations. |
148 const unsigned int index_; | 150 const unsigned int index_; |
149 // Used only in write operations. | 151 // Used only in write operations. |
150 const bool truncate_; | 152 const bool truncate_; |
151 const bool optimistic_; | 153 const bool optimistic_; |
152 // Used only in SimpleCache.ReadIsParallelizable histogram. | 154 // Used only in SimpleCache.ReadIsParallelizable histogram. |
153 const bool alone_in_queue_; | 155 const bool alone_in_queue_; |
154 }; | 156 }; |
155 | 157 |
156 } // namespace disk_cache | 158 } // namespace disk_cache |
157 | 159 |
158 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_OPERATION_H_ | 160 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_OPERATION_H_ |
OLD | NEW |