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" |
| 11 #include "base/profiler/scoped_profile.h" |
11 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
12 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
13 #include "net/disk_cache/blockfile/backend_impl.h" | 14 #include "net/disk_cache/blockfile/backend_impl.h" |
14 #include "net/disk_cache/blockfile/entry_impl.h" | 15 #include "net/disk_cache/blockfile/entry_impl.h" |
15 #include "net/disk_cache/blockfile/histogram_macros.h" | 16 #include "net/disk_cache/blockfile/histogram_macros.h" |
16 | 17 |
17 // Provide a BackendImpl object to macros from histogram_macros.h. | 18 // Provide a BackendImpl object to macros from histogram_macros.h. |
18 #define CACHE_UMA_BACKEND_IMPL_OBJ backend_ | 19 #define CACHE_UMA_BACKEND_IMPL_OBJ backend_ |
19 | 20 |
20 namespace disk_cache { | 21 namespace disk_cache { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 void BackendIO::OnDone(bool cancel) { | 58 void BackendIO::OnDone(bool cancel) { |
58 if (IsEntryOperation()) { | 59 if (IsEntryOperation()) { |
59 CACHE_UMA(TIMES, "TotalIOTime", 0, ElapsedTime()); | 60 CACHE_UMA(TIMES, "TotalIOTime", 0, ElapsedTime()); |
60 } | 61 } |
61 | 62 |
62 if (!ReturnsEntry()) | 63 if (!ReturnsEntry()) |
63 return; | 64 return; |
64 | 65 |
65 if (result() == net::OK) { | 66 if (result() == net::OK) { |
66 static_cast<EntryImpl*>(*entry_ptr_)->OnEntryCreated(backend_); | 67 static_cast<EntryImpl*>(*entry_ptr_)->OnEntryCreated(backend_); |
67 if (cancel) | 68 if (cancel) { |
| 69 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422516 is |
| 70 // fixed. |
| 71 tracked_objects::ScopedProfile tracking_profile( |
| 72 FROM_HERE_WITH_EXPLICIT_FUNCTION("422516 BackendIO::OnDone")); |
| 73 |
68 (*entry_ptr_)->Close(); | 74 (*entry_ptr_)->Close(); |
| 75 } |
69 } | 76 } |
70 } | 77 } |
71 | 78 |
72 bool BackendIO::IsEntryOperation() { | 79 bool BackendIO::IsEntryOperation() { |
73 return operation_ > OP_MAX_BACKEND; | 80 return operation_ > OP_MAX_BACKEND; |
74 } | 81 } |
75 | 82 |
76 // Runs on the background thread. | 83 // Runs on the background thread. |
77 void BackendIO::ReferenceEntry() { | 84 void BackendIO::ReferenceEntry() { |
78 entry_->AddRef(); | 85 entry_->AddRef(); |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 | 496 |
490 void InFlightBackendIO::WaitForPendingIO() { | 497 void InFlightBackendIO::WaitForPendingIO() { |
491 InFlightIO::WaitForPendingIO(); | 498 InFlightIO::WaitForPendingIO(); |
492 } | 499 } |
493 | 500 |
494 void InFlightBackendIO::OnOperationComplete(BackgroundIO* operation, | 501 void InFlightBackendIO::OnOperationComplete(BackgroundIO* operation, |
495 bool cancel) { | 502 bool cancel) { |
496 BackendIO* op = static_cast<BackendIO*>(operation); | 503 BackendIO* op = static_cast<BackendIO*>(operation); |
497 op->OnDone(cancel); | 504 op->OnDone(cancel); |
498 | 505 |
499 if (!op->callback().is_null() && (!cancel || op->IsEntryOperation())) | 506 if (!op->callback().is_null() && (!cancel || op->IsEntryOperation())) { |
| 507 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422516 is fixed. |
| 508 tracked_objects::ScopedProfile tracking_profile( |
| 509 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 510 "422516 InFlightBackendIO::OnOperationComplete")); |
| 511 |
500 op->callback().Run(op->result()); | 512 op->callback().Run(op->result()); |
| 513 } |
501 } | 514 } |
502 | 515 |
503 void InFlightBackendIO::PostOperation(BackendIO* operation) { | 516 void InFlightBackendIO::PostOperation(BackendIO* operation) { |
504 background_thread_->PostTask( | 517 background_thread_->PostTask( |
505 FROM_HERE, base::Bind(&BackendIO::ExecuteOperation, operation)); | 518 FROM_HERE, base::Bind(&BackendIO::ExecuteOperation, operation)); |
506 OnOperationPosted(operation); | 519 OnOperationPosted(operation); |
507 } | 520 } |
508 | 521 |
509 base::WeakPtr<InFlightBackendIO> InFlightBackendIO::GetWeakPtr() { | 522 base::WeakPtr<InFlightBackendIO> InFlightBackendIO::GetWeakPtr() { |
510 return ptr_factory_.GetWeakPtr(); | 523 return ptr_factory_.GetWeakPtr(); |
511 } | 524 } |
512 | 525 |
513 } // namespace | 526 } // namespace |
OLD | NEW |