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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 const scoped_refptr<base::SingleThreadTaskRunner>& background_thread) | 334 const scoped_refptr<base::SingleThreadTaskRunner>& background_thread) |
335 : backend_(backend), | 335 : backend_(backend), |
336 background_thread_(background_thread), | 336 background_thread_(background_thread), |
337 ptr_factory_(this) { | 337 ptr_factory_(this) { |
338 } | 338 } |
339 | 339 |
340 InFlightBackendIO::~InFlightBackendIO() { | 340 InFlightBackendIO::~InFlightBackendIO() { |
341 } | 341 } |
342 | 342 |
343 void InFlightBackendIO::Init(const net::CompletionCallback& callback) { | 343 void InFlightBackendIO::Init(const net::CompletionCallback& callback) { |
344 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 344 // TODO(vadimt): Remove wrapping the callback with |
| 345 // ScopedTracker::TrackCallback() once crbug.com/422516 is fixed. |
| 346 scoped_refptr<BackendIO> operation(new BackendIO( |
| 347 this, backend_, |
| 348 tracked_objects::ScopedTracker::TrackCallback( |
| 349 FROM_HERE_WITH_EXPLICIT_FUNCTION("422516 InFlightBackendIO::Init"), |
| 350 callback))); |
345 operation->Init(); | 351 operation->Init(); |
346 PostOperation(operation.get()); | 352 PostOperation(operation.get()); |
347 } | 353 } |
348 | 354 |
349 void InFlightBackendIO::OpenEntry(const std::string& key, Entry** entry, | 355 void InFlightBackendIO::OpenEntry(const std::string& key, Entry** entry, |
350 const net::CompletionCallback& callback) { | 356 const net::CompletionCallback& callback) { |
351 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 357 scoped_refptr<BackendIO> operation(new BackendIO( |
| 358 this, backend_, tracked_objects::ScopedTracker::TrackCallback( |
| 359 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 360 "422516 InFlightBackendIO::OpenEntry"), |
| 361 callback))); |
352 operation->OpenEntry(key, entry); | 362 operation->OpenEntry(key, entry); |
353 PostOperation(operation.get()); | 363 PostOperation(operation.get()); |
354 } | 364 } |
355 | 365 |
356 void InFlightBackendIO::CreateEntry(const std::string& key, Entry** entry, | 366 void InFlightBackendIO::CreateEntry(const std::string& key, Entry** entry, |
357 const net::CompletionCallback& callback) { | 367 const net::CompletionCallback& callback) { |
358 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 368 scoped_refptr<BackendIO> operation(new BackendIO( |
| 369 this, backend_, tracked_objects::ScopedTracker::TrackCallback( |
| 370 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 371 "422516 InFlightBackendIO::CreateEntry"), |
| 372 callback))); |
359 operation->CreateEntry(key, entry); | 373 operation->CreateEntry(key, entry); |
360 PostOperation(operation.get()); | 374 PostOperation(operation.get()); |
361 } | 375 } |
362 | 376 |
363 void InFlightBackendIO::DoomEntry(const std::string& key, | 377 void InFlightBackendIO::DoomEntry(const std::string& key, |
364 const net::CompletionCallback& callback) { | 378 const net::CompletionCallback& callback) { |
365 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 379 scoped_refptr<BackendIO> operation(new BackendIO( |
| 380 this, backend_, tracked_objects::ScopedTracker::TrackCallback( |
| 381 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 382 "422516 InFlightBackendIO::DoomEntry"), |
| 383 callback))); |
366 operation->DoomEntry(key); | 384 operation->DoomEntry(key); |
367 PostOperation(operation.get()); | 385 PostOperation(operation.get()); |
368 } | 386 } |
369 | 387 |
370 void InFlightBackendIO::DoomAllEntries( | 388 void InFlightBackendIO::DoomAllEntries( |
371 const net::CompletionCallback& callback) { | 389 const net::CompletionCallback& callback) { |
372 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 390 scoped_refptr<BackendIO> operation(new BackendIO( |
| 391 this, backend_, tracked_objects::ScopedTracker::TrackCallback( |
| 392 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 393 "422516 InFlightBackendIO::DoomAllEntries"), |
| 394 callback))); |
373 operation->DoomAllEntries(); | 395 operation->DoomAllEntries(); |
374 PostOperation(operation.get()); | 396 PostOperation(operation.get()); |
375 } | 397 } |
376 | 398 |
377 void InFlightBackendIO::DoomEntriesBetween(const base::Time initial_time, | 399 void InFlightBackendIO::DoomEntriesBetween(const base::Time initial_time, |
378 const base::Time end_time, | 400 const base::Time end_time, |
379 const net::CompletionCallback& callback) { | 401 const net::CompletionCallback& callback) { |
380 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 402 scoped_refptr<BackendIO> operation(new BackendIO( |
| 403 this, backend_, tracked_objects::ScopedTracker::TrackCallback( |
| 404 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 405 "422516 InFlightBackendIO::DoomEntriesBetween"), |
| 406 callback))); |
381 operation->DoomEntriesBetween(initial_time, end_time); | 407 operation->DoomEntriesBetween(initial_time, end_time); |
382 PostOperation(operation.get()); | 408 PostOperation(operation.get()); |
383 } | 409 } |
384 | 410 |
385 void InFlightBackendIO::DoomEntriesSince( | 411 void InFlightBackendIO::DoomEntriesSince( |
386 const base::Time initial_time, const net::CompletionCallback& callback) { | 412 const base::Time initial_time, const net::CompletionCallback& callback) { |
387 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 413 scoped_refptr<BackendIO> operation(new BackendIO( |
| 414 this, backend_, tracked_objects::ScopedTracker::TrackCallback( |
| 415 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 416 "422516 InFlightBackendIO::DoomEntriesSince"), |
| 417 callback))); |
388 operation->DoomEntriesSince(initial_time); | 418 operation->DoomEntriesSince(initial_time); |
389 PostOperation(operation.get()); | 419 PostOperation(operation.get()); |
390 } | 420 } |
391 | 421 |
392 void InFlightBackendIO::OpenNextEntry(Rankings::Iterator* iterator, | 422 void InFlightBackendIO::OpenNextEntry(Rankings::Iterator* iterator, |
393 Entry** next_entry, | 423 Entry** next_entry, |
394 const net::CompletionCallback& callback) { | 424 const net::CompletionCallback& callback) { |
395 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 425 scoped_refptr<BackendIO> operation(new BackendIO( |
| 426 this, backend_, tracked_objects::ScopedTracker::TrackCallback( |
| 427 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 428 "422516 InFlightBackendIO::OpenNextEntry"), |
| 429 callback))); |
396 operation->OpenNextEntry(iterator, next_entry); | 430 operation->OpenNextEntry(iterator, next_entry); |
397 PostOperation(operation.get()); | 431 PostOperation(operation.get()); |
398 } | 432 } |
399 | 433 |
400 void InFlightBackendIO::EndEnumeration( | 434 void InFlightBackendIO::EndEnumeration( |
401 scoped_ptr<Rankings::Iterator> iterator) { | 435 scoped_ptr<Rankings::Iterator> iterator) { |
402 scoped_refptr<BackendIO> operation( | 436 scoped_refptr<BackendIO> operation( |
403 new BackendIO(this, backend_, net::CompletionCallback())); | 437 new BackendIO(this, backend_, net::CompletionCallback())); |
404 operation->EndEnumeration(iterator.Pass()); | 438 operation->EndEnumeration(iterator.Pass()); |
405 PostOperation(operation.get()); | 439 PostOperation(operation.get()); |
(...skipping 14 matching lines...) Expand all Loading... |
420 } | 454 } |
421 | 455 |
422 void InFlightBackendIO::DoomEntryImpl(EntryImpl* entry) { | 456 void InFlightBackendIO::DoomEntryImpl(EntryImpl* entry) { |
423 scoped_refptr<BackendIO> operation( | 457 scoped_refptr<BackendIO> operation( |
424 new BackendIO(this, backend_, net::CompletionCallback())); | 458 new BackendIO(this, backend_, net::CompletionCallback())); |
425 operation->DoomEntryImpl(entry); | 459 operation->DoomEntryImpl(entry); |
426 PostOperation(operation.get()); | 460 PostOperation(operation.get()); |
427 } | 461 } |
428 | 462 |
429 void InFlightBackendIO::FlushQueue(const net::CompletionCallback& callback) { | 463 void InFlightBackendIO::FlushQueue(const net::CompletionCallback& callback) { |
430 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 464 scoped_refptr<BackendIO> operation(new BackendIO( |
| 465 this, backend_, tracked_objects::ScopedTracker::TrackCallback( |
| 466 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 467 "422516 InFlightBackendIO::FlushQueue"), |
| 468 callback))); |
431 operation->FlushQueue(); | 469 operation->FlushQueue(); |
432 PostOperation(operation.get()); | 470 PostOperation(operation.get()); |
433 } | 471 } |
434 | 472 |
435 void InFlightBackendIO::RunTask( | 473 void InFlightBackendIO::RunTask( |
436 const base::Closure& task, const net::CompletionCallback& callback) { | 474 const base::Closure& task, const net::CompletionCallback& callback) { |
437 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 475 scoped_refptr<BackendIO> operation(new BackendIO( |
| 476 this, backend_, |
| 477 tracked_objects::ScopedTracker::TrackCallback( |
| 478 FROM_HERE_WITH_EXPLICIT_FUNCTION("422516 InFlightBackendIO::RunTask"), |
| 479 callback))); |
438 operation->RunTask(task); | 480 operation->RunTask(task); |
439 PostOperation(operation.get()); | 481 PostOperation(operation.get()); |
440 } | 482 } |
441 | 483 |
442 void InFlightBackendIO::ReadData(EntryImpl* entry, int index, int offset, | 484 void InFlightBackendIO::ReadData(EntryImpl* entry, int index, int offset, |
443 net::IOBuffer* buf, int buf_len, | 485 net::IOBuffer* buf, int buf_len, |
444 const net::CompletionCallback& callback) { | 486 const net::CompletionCallback& callback) { |
445 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 487 scoped_refptr<BackendIO> operation(new BackendIO( |
| 488 this, backend_, tracked_objects::ScopedTracker::TrackCallback( |
| 489 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 490 "422516 InFlightBackendIO::ReadData"), |
| 491 callback))); |
446 operation->ReadData(entry, index, offset, buf, buf_len); | 492 operation->ReadData(entry, index, offset, buf, buf_len); |
447 PostOperation(operation.get()); | 493 PostOperation(operation.get()); |
448 } | 494 } |
449 | 495 |
450 void InFlightBackendIO::WriteData(EntryImpl* entry, int index, int offset, | 496 void InFlightBackendIO::WriteData(EntryImpl* entry, int index, int offset, |
451 net::IOBuffer* buf, int buf_len, | 497 net::IOBuffer* buf, int buf_len, |
452 bool truncate, | 498 bool truncate, |
453 const net::CompletionCallback& callback) { | 499 const net::CompletionCallback& callback) { |
454 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 500 scoped_refptr<BackendIO> operation(new BackendIO( |
| 501 this, backend_, tracked_objects::ScopedTracker::TrackCallback( |
| 502 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 503 "422516 InFlightBackendIO::WriteData"), |
| 504 callback))); |
455 operation->WriteData(entry, index, offset, buf, buf_len, truncate); | 505 operation->WriteData(entry, index, offset, buf, buf_len, truncate); |
456 PostOperation(operation.get()); | 506 PostOperation(operation.get()); |
457 } | 507 } |
458 | 508 |
459 void InFlightBackendIO::ReadSparseData( | 509 void InFlightBackendIO::ReadSparseData( |
460 EntryImpl* entry, int64 offset, net::IOBuffer* buf, int buf_len, | 510 EntryImpl* entry, int64 offset, net::IOBuffer* buf, int buf_len, |
461 const net::CompletionCallback& callback) { | 511 const net::CompletionCallback& callback) { |
462 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 512 scoped_refptr<BackendIO> operation(new BackendIO( |
| 513 this, backend_, tracked_objects::ScopedTracker::TrackCallback( |
| 514 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 515 "422516 InFlightBackendIO::ReadSparseData"), |
| 516 callback))); |
463 operation->ReadSparseData(entry, offset, buf, buf_len); | 517 operation->ReadSparseData(entry, offset, buf, buf_len); |
464 PostOperation(operation.get()); | 518 PostOperation(operation.get()); |
465 } | 519 } |
466 | 520 |
467 void InFlightBackendIO::WriteSparseData( | 521 void InFlightBackendIO::WriteSparseData( |
468 EntryImpl* entry, int64 offset, net::IOBuffer* buf, int buf_len, | 522 EntryImpl* entry, int64 offset, net::IOBuffer* buf, int buf_len, |
469 const net::CompletionCallback& callback) { | 523 const net::CompletionCallback& callback) { |
470 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 524 scoped_refptr<BackendIO> operation(new BackendIO( |
| 525 this, backend_, tracked_objects::ScopedTracker::TrackCallback( |
| 526 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 527 "422516 InFlightBackendIO::WriteSparseData"), |
| 528 callback))); |
471 operation->WriteSparseData(entry, offset, buf, buf_len); | 529 operation->WriteSparseData(entry, offset, buf, buf_len); |
472 PostOperation(operation.get()); | 530 PostOperation(operation.get()); |
473 } | 531 } |
474 | 532 |
475 void InFlightBackendIO::GetAvailableRange( | 533 void InFlightBackendIO::GetAvailableRange( |
476 EntryImpl* entry, int64 offset, int len, int64* start, | 534 EntryImpl* entry, int64 offset, int len, int64* start, |
477 const net::CompletionCallback& callback) { | 535 const net::CompletionCallback& callback) { |
478 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 536 scoped_refptr<BackendIO> operation(new BackendIO( |
| 537 this, backend_, tracked_objects::ScopedTracker::TrackCallback( |
| 538 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 539 "422516 InFlightBackendIO::GetAvailableRange"), |
| 540 callback))); |
479 operation->GetAvailableRange(entry, offset, len, start); | 541 operation->GetAvailableRange(entry, offset, len, start); |
480 PostOperation(operation.get()); | 542 PostOperation(operation.get()); |
481 } | 543 } |
482 | 544 |
483 void InFlightBackendIO::CancelSparseIO(EntryImpl* entry) { | 545 void InFlightBackendIO::CancelSparseIO(EntryImpl* entry) { |
484 scoped_refptr<BackendIO> operation( | 546 scoped_refptr<BackendIO> operation( |
485 new BackendIO(this, backend_, net::CompletionCallback())); | 547 new BackendIO(this, backend_, net::CompletionCallback())); |
486 operation->CancelSparseIO(entry); | 548 operation->CancelSparseIO(entry); |
487 PostOperation(operation.get()); | 549 PostOperation(operation.get()); |
488 } | 550 } |
489 | 551 |
490 void InFlightBackendIO::ReadyForSparseIO( | 552 void InFlightBackendIO::ReadyForSparseIO( |
491 EntryImpl* entry, const net::CompletionCallback& callback) { | 553 EntryImpl* entry, const net::CompletionCallback& callback) { |
492 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 554 scoped_refptr<BackendIO> operation(new BackendIO( |
| 555 this, backend_, tracked_objects::ScopedTracker::TrackCallback( |
| 556 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 557 "422516 InFlightBackendIO::CancelSparseIO"), |
| 558 callback))); |
493 operation->ReadyForSparseIO(entry); | 559 operation->ReadyForSparseIO(entry); |
494 PostOperation(operation.get()); | 560 PostOperation(operation.get()); |
495 } | 561 } |
496 | 562 |
497 void InFlightBackendIO::WaitForPendingIO() { | 563 void InFlightBackendIO::WaitForPendingIO() { |
498 InFlightIO::WaitForPendingIO(); | 564 InFlightIO::WaitForPendingIO(); |
499 } | 565 } |
500 | 566 |
501 void InFlightBackendIO::OnOperationComplete(BackgroundIO* operation, | 567 void InFlightBackendIO::OnOperationComplete(BackgroundIO* operation, |
502 bool cancel) { | 568 bool cancel) { |
(...skipping 14 matching lines...) Expand all Loading... |
517 background_thread_->PostTask( | 583 background_thread_->PostTask( |
518 FROM_HERE, base::Bind(&BackendIO::ExecuteOperation, operation)); | 584 FROM_HERE, base::Bind(&BackendIO::ExecuteOperation, operation)); |
519 OnOperationPosted(operation); | 585 OnOperationPosted(operation); |
520 } | 586 } |
521 | 587 |
522 base::WeakPtr<InFlightBackendIO> InFlightBackendIO::GetWeakPtr() { | 588 base::WeakPtr<InFlightBackendIO> InFlightBackendIO::GetWeakPtr() { |
523 return ptr_factory_.GetWeakPtr(); | 589 return ptr_factory_.GetWeakPtr(); |
524 } | 590 } |
525 | 591 |
526 } // namespace | 592 } // namespace |
OLD | NEW |