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 #include "net/disk_cache/blockfile/in_flight_backend_io.h" | 5 #include "net/disk_cache/blockfile/in_flight_backend_io.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 net::IOBuffer* buf, int buf_len, bool truncate) { | 169 net::IOBuffer* buf, int buf_len, bool truncate) { |
170 operation_ = OP_WRITE; | 170 operation_ = OP_WRITE; |
171 entry_ = entry; | 171 entry_ = entry; |
172 index_ = index; | 172 index_ = index; |
173 offset_ = offset; | 173 offset_ = offset; |
174 buf_ = buf; | 174 buf_ = buf; |
175 buf_len_ = buf_len; | 175 buf_len_ = buf_len; |
176 truncate_ = truncate; | 176 truncate_ = truncate; |
177 } | 177 } |
178 | 178 |
179 void BackendIO::ReadSparseData(EntryImpl* entry, int64 offset, | 179 void BackendIO::ReadSparseData(EntryImpl* entry, |
180 net::IOBuffer* buf, int buf_len) { | 180 int64_t offset, |
| 181 net::IOBuffer* buf, |
| 182 int buf_len) { |
181 operation_ = OP_READ_SPARSE; | 183 operation_ = OP_READ_SPARSE; |
182 entry_ = entry; | 184 entry_ = entry; |
183 offset64_ = offset; | 185 offset64_ = offset; |
184 buf_ = buf; | 186 buf_ = buf; |
185 buf_len_ = buf_len; | 187 buf_len_ = buf_len; |
186 } | 188 } |
187 | 189 |
188 void BackendIO::WriteSparseData(EntryImpl* entry, int64 offset, | 190 void BackendIO::WriteSparseData(EntryImpl* entry, |
189 net::IOBuffer* buf, int buf_len) { | 191 int64_t offset, |
| 192 net::IOBuffer* buf, |
| 193 int buf_len) { |
190 operation_ = OP_WRITE_SPARSE; | 194 operation_ = OP_WRITE_SPARSE; |
191 entry_ = entry; | 195 entry_ = entry; |
192 offset64_ = offset; | 196 offset64_ = offset; |
193 buf_ = buf; | 197 buf_ = buf; |
194 buf_len_ = buf_len; | 198 buf_len_ = buf_len; |
195 } | 199 } |
196 | 200 |
197 void BackendIO::GetAvailableRange(EntryImpl* entry, int64 offset, int len, | 201 void BackendIO::GetAvailableRange(EntryImpl* entry, |
198 int64* start) { | 202 int64_t offset, |
| 203 int len, |
| 204 int64_t* start) { |
199 operation_ = OP_GET_RANGE; | 205 operation_ = OP_GET_RANGE; |
200 entry_ = entry; | 206 entry_ = entry; |
201 offset64_ = offset; | 207 offset64_ = offset; |
202 buf_len_ = len; | 208 buf_len_ = len; |
203 start_ = start; | 209 start_ = start; |
204 } | 210 } |
205 | 211 |
206 void BackendIO::CancelSparseIO(EntryImpl* entry) { | 212 void BackendIO::CancelSparseIO(EntryImpl* entry) { |
207 operation_ = OP_CANCEL_IO; | 213 operation_ = OP_CANCEL_IO; |
208 entry_ = entry; | 214 entry_ = entry; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 void InFlightBackendIO::WriteData(EntryImpl* entry, int index, int offset, | 463 void InFlightBackendIO::WriteData(EntryImpl* entry, int index, int offset, |
458 net::IOBuffer* buf, int buf_len, | 464 net::IOBuffer* buf, int buf_len, |
459 bool truncate, | 465 bool truncate, |
460 const net::CompletionCallback& callback) { | 466 const net::CompletionCallback& callback) { |
461 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 467 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); |
462 operation->WriteData(entry, index, offset, buf, buf_len, truncate); | 468 operation->WriteData(entry, index, offset, buf, buf_len, truncate); |
463 PostOperation(operation.get()); | 469 PostOperation(operation.get()); |
464 } | 470 } |
465 | 471 |
466 void InFlightBackendIO::ReadSparseData( | 472 void InFlightBackendIO::ReadSparseData( |
467 EntryImpl* entry, int64 offset, net::IOBuffer* buf, int buf_len, | 473 EntryImpl* entry, |
| 474 int64_t offset, |
| 475 net::IOBuffer* buf, |
| 476 int buf_len, |
468 const net::CompletionCallback& callback) { | 477 const net::CompletionCallback& callback) { |
469 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 478 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); |
470 operation->ReadSparseData(entry, offset, buf, buf_len); | 479 operation->ReadSparseData(entry, offset, buf, buf_len); |
471 PostOperation(operation.get()); | 480 PostOperation(operation.get()); |
472 } | 481 } |
473 | 482 |
474 void InFlightBackendIO::WriteSparseData( | 483 void InFlightBackendIO::WriteSparseData( |
475 EntryImpl* entry, int64 offset, net::IOBuffer* buf, int buf_len, | 484 EntryImpl* entry, |
| 485 int64_t offset, |
| 486 net::IOBuffer* buf, |
| 487 int buf_len, |
476 const net::CompletionCallback& callback) { | 488 const net::CompletionCallback& callback) { |
477 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 489 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); |
478 operation->WriteSparseData(entry, offset, buf, buf_len); | 490 operation->WriteSparseData(entry, offset, buf, buf_len); |
479 PostOperation(operation.get()); | 491 PostOperation(operation.get()); |
480 } | 492 } |
481 | 493 |
482 void InFlightBackendIO::GetAvailableRange( | 494 void InFlightBackendIO::GetAvailableRange( |
483 EntryImpl* entry, int64 offset, int len, int64* start, | 495 EntryImpl* entry, |
| 496 int64_t offset, |
| 497 int len, |
| 498 int64_t* start, |
484 const net::CompletionCallback& callback) { | 499 const net::CompletionCallback& callback) { |
485 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 500 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); |
486 operation->GetAvailableRange(entry, offset, len, start); | 501 operation->GetAvailableRange(entry, offset, len, start); |
487 PostOperation(operation.get()); | 502 PostOperation(operation.get()); |
488 } | 503 } |
489 | 504 |
490 void InFlightBackendIO::CancelSparseIO(EntryImpl* entry) { | 505 void InFlightBackendIO::CancelSparseIO(EntryImpl* entry) { |
491 scoped_refptr<BackendIO> operation( | 506 scoped_refptr<BackendIO> operation( |
492 new BackendIO(this, backend_, net::CompletionCallback())); | 507 new BackendIO(this, backend_, net::CompletionCallback())); |
493 operation->CancelSparseIO(entry); | 508 operation->CancelSparseIO(entry); |
(...skipping 24 matching lines...) Expand all Loading... |
518 background_thread_->PostTask( | 533 background_thread_->PostTask( |
519 FROM_HERE, base::Bind(&BackendIO::ExecuteOperation, operation)); | 534 FROM_HERE, base::Bind(&BackendIO::ExecuteOperation, operation)); |
520 OnOperationPosted(operation); | 535 OnOperationPosted(operation); |
521 } | 536 } |
522 | 537 |
523 base::WeakPtr<InFlightBackendIO> InFlightBackendIO::GetWeakPtr() { | 538 base::WeakPtr<InFlightBackendIO> InFlightBackendIO::GetWeakPtr() { |
524 return ptr_factory_.GetWeakPtr(); | 539 return ptr_factory_.GetWeakPtr(); |
525 } | 540 } |
526 | 541 |
527 } // namespace | 542 } // namespace |
OLD | NEW |