OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "net/disk_cache/in_flight_backend_io.h" | 5 #include "net/disk_cache/in_flight_backend_io.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "net/base/net_log.h" |
10 #include "net/disk_cache/backend_impl.h" | 11 #include "net/disk_cache/backend_impl.h" |
11 #include "net/disk_cache/entry_impl.h" | 12 #include "net/disk_cache/entry_impl.h" |
12 #include "net/disk_cache/histogram_macros.h" | 13 #include "net/disk_cache/histogram_macros.h" |
13 | 14 |
14 namespace disk_cache { | 15 namespace disk_cache { |
15 | 16 |
16 BackendIO::BackendIO(InFlightIO* controller, BackendImpl* backend, | 17 BackendIO::BackendIO(InFlightIO* controller, BackendImpl* backend, |
17 net::CompletionCallback* callback) | 18 net::CompletionCallback* callback) |
18 : BackgroundIO(controller), backend_(backend), callback_(callback), | 19 : BackgroundIO(controller), backend_(backend), callback_(callback), |
19 operation_(OP_NONE), | 20 operation_(OP_NONE), |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 } | 102 } |
102 | 103 |
103 void BackendIO::EndEnumeration(void* iterator) { | 104 void BackendIO::EndEnumeration(void* iterator) { |
104 operation_ = OP_END_ENUMERATION; | 105 operation_ = OP_END_ENUMERATION; |
105 iter_ = iterator; | 106 iter_ = iterator; |
106 } | 107 } |
107 | 108 |
108 void BackendIO::CloseEntryImpl(EntryImpl* entry) { | 109 void BackendIO::CloseEntryImpl(EntryImpl* entry) { |
109 operation_ = OP_CLOSE_ENTRY; | 110 operation_ = OP_CLOSE_ENTRY; |
110 entry_ = entry; | 111 entry_ = entry; |
| 112 if (entry->net_log().IsLoggingAllEvents()) |
| 113 entry->net_log().AddEvent(net::NetLog::TYPE_DISK_CACHE_QUEUE_CLOSE, NULL); |
111 } | 114 } |
112 | 115 |
113 void BackendIO::DoomEntryImpl(EntryImpl* entry) { | 116 void BackendIO::DoomEntryImpl(EntryImpl* entry) { |
114 operation_ = OP_DOOM_ENTRY; | 117 operation_ = OP_DOOM_ENTRY; |
115 entry_ = entry; | 118 entry_ = entry; |
| 119 if (entry->net_log().IsLoggingAllEvents()) |
| 120 entry->net_log().AddEvent(net::NetLog::TYPE_DISK_CACHE_QUEUE_DOOM, NULL); |
116 } | 121 } |
117 | 122 |
118 void BackendIO::FlushQueue() { | 123 void BackendIO::FlushQueue() { |
119 operation_ = OP_FLUSH_QUEUE; | 124 operation_ = OP_FLUSH_QUEUE; |
120 } | 125 } |
121 | 126 |
122 void BackendIO::RunTask(Task* task) { | 127 void BackendIO::RunTask(Task* task) { |
123 operation_ = OP_RUN_TASK; | 128 operation_ = OP_RUN_TASK; |
124 task_ = task; | 129 task_ = task; |
125 } | 130 } |
126 | 131 |
127 void BackendIO::ReadData(EntryImpl* entry, int index, int offset, | 132 void BackendIO::ReadData(EntryImpl* entry, int index, int offset, |
128 net::IOBuffer* buf, int buf_len) { | 133 net::IOBuffer* buf, int buf_len) { |
129 operation_ = OP_READ; | 134 operation_ = OP_READ; |
130 entry_ = entry; | 135 entry_ = entry; |
131 index_ = index; | 136 index_ = index; |
132 offset_ = offset; | 137 offset_ = offset; |
133 buf_ = buf; | 138 buf_ = buf; |
134 buf_len_ = buf_len; | 139 buf_len_ = buf_len; |
| 140 |
| 141 if (entry->net_log().IsLoggingAllEvents()) { |
| 142 entry->net_log().AddEvent(net::NetLog::TYPE_DISK_CACHE_QUEUE_READ_DATA, |
| 143 NULL); |
| 144 } |
135 } | 145 } |
136 | 146 |
137 void BackendIO::WriteData(EntryImpl* entry, int index, int offset, | 147 void BackendIO::WriteData(EntryImpl* entry, int index, int offset, |
138 net::IOBuffer* buf, int buf_len, bool truncate) { | 148 net::IOBuffer* buf, int buf_len, bool truncate) { |
139 operation_ = OP_WRITE; | 149 operation_ = OP_WRITE; |
140 entry_ = entry; | 150 entry_ = entry; |
141 index_ = index; | 151 index_ = index; |
142 offset_ = offset; | 152 offset_ = offset; |
143 buf_ = buf; | 153 buf_ = buf; |
144 buf_len_ = buf_len; | 154 buf_len_ = buf_len; |
145 truncate_ = truncate; | 155 truncate_ = truncate; |
| 156 |
| 157 if (entry->net_log().IsLoggingAllEvents()) { |
| 158 entry->net_log().AddEvent(net::NetLog::TYPE_DISK_CACHE_QUEUE_WRITE_DATA, |
| 159 NULL); |
| 160 } |
146 } | 161 } |
147 | 162 |
148 void BackendIO::ReadSparseData(EntryImpl* entry, int64 offset, | 163 void BackendIO::ReadSparseData(EntryImpl* entry, int64 offset, |
149 net::IOBuffer* buf, int buf_len) { | 164 net::IOBuffer* buf, int buf_len) { |
150 operation_ = OP_READ_SPARSE; | 165 operation_ = OP_READ_SPARSE; |
151 entry_ = entry; | 166 entry_ = entry; |
152 offset64_ = offset; | 167 offset64_ = offset; |
153 buf_ = buf; | 168 buf_ = buf; |
154 buf_len_ = buf_len; | 169 buf_len_ = buf_len; |
| 170 |
| 171 if (entry->net_log().IsLoggingAllEvents()) { |
| 172 entry->net_log().AddEvent(net::NetLog::TYPE_DISK_CACHE_QUEUE_READ_SPARSE, |
| 173 NULL); |
| 174 } |
155 } | 175 } |
156 | 176 |
157 void BackendIO::WriteSparseData(EntryImpl* entry, int64 offset, | 177 void BackendIO::WriteSparseData(EntryImpl* entry, int64 offset, |
158 net::IOBuffer* buf, int buf_len) { | 178 net::IOBuffer* buf, int buf_len) { |
159 operation_ = OP_WRITE_SPARSE; | 179 operation_ = OP_WRITE_SPARSE; |
160 entry_ = entry; | 180 entry_ = entry; |
161 offset64_ = offset; | 181 offset64_ = offset; |
162 buf_ = buf; | 182 buf_ = buf; |
163 buf_len_ = buf_len; | 183 buf_len_ = buf_len; |
| 184 |
| 185 if (entry->net_log().IsLoggingAllEvents()) { |
| 186 entry->net_log().AddEvent(net::NetLog::TYPE_DISK_CACHE_QUEUE_WRITE_SPARSE, |
| 187 NULL); |
| 188 } |
164 } | 189 } |
165 | 190 |
166 void BackendIO::GetAvailableRange(EntryImpl* entry, int64 offset, int len, | 191 void BackendIO::GetAvailableRange(EntryImpl* entry, int64 offset, int len, |
167 int64* start) { | 192 int64* start) { |
168 operation_ = OP_GET_RANGE; | 193 operation_ = OP_GET_RANGE; |
169 entry_ = entry; | 194 entry_ = entry; |
170 offset64_ = offset; | 195 offset64_ = offset; |
171 buf_len_ = len; | 196 buf_len_ = len; |
172 start_ = start; | 197 start_ = start; |
| 198 |
| 199 if (entry->net_log().IsLoggingAllEvents()) { |
| 200 entry->net_log().AddEvent(net::NetLog::TYPE_DISK_CACHE_QUEUE_GET_RANGE, |
| 201 NULL); |
| 202 } |
173 } | 203 } |
174 | 204 |
175 void BackendIO::CancelSparseIO(EntryImpl* entry) { | 205 void BackendIO::CancelSparseIO(EntryImpl* entry) { |
176 operation_ = OP_CANCEL_IO; | 206 operation_ = OP_CANCEL_IO; |
177 entry_ = entry; | 207 entry_ = entry; |
178 } | 208 } |
179 | 209 |
180 void BackendIO::ReadyForSparseIO(EntryImpl* entry) { | 210 void BackendIO::ReadyForSparseIO(EntryImpl* entry) { |
181 operation_ = OP_IS_READY; | 211 operation_ = OP_IS_READY; |
182 entry_ = entry; | 212 entry_ = entry; |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 DCHECK(!pending_ops_.empty()); | 559 DCHECK(!pending_ops_.empty()); |
530 scoped_refptr<BackendIO> next_op = pending_ops_.front(); | 560 scoped_refptr<BackendIO> next_op = pending_ops_.front(); |
531 if (operation != next_op) | 561 if (operation != next_op) |
532 return false; | 562 return false; |
533 | 563 |
534 pending_ops_.pop_front(); | 564 pending_ops_.pop_front(); |
535 return true; | 565 return true; |
536 } | 566 } |
537 | 567 |
538 } // namespace | 568 } // namespace |
OLD | NEW |