| 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_io.h" | 5 #include "net/disk_cache/blockfile/in_flight_io.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/profiler/scoped_tracker.h" | 9 #include "base/profiler/scoped_tracker.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/task_runner.h" | 11 #include "base/task_runner.h" |
| 12 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 15 #include "net/base/trace_constants.h" |
| 15 | 16 |
| 16 namespace disk_cache { | 17 namespace disk_cache { |
| 17 | 18 |
| 18 BackgroundIO::BackgroundIO(InFlightIO* controller) | 19 BackgroundIO::BackgroundIO(InFlightIO* controller) |
| 19 : result_(-1), | 20 : result_(-1), |
| 20 io_completed_(base::WaitableEvent::ResetPolicy::MANUAL, | 21 io_completed_(base::WaitableEvent::ResetPolicy::MANUAL, |
| 21 base::WaitableEvent::InitialState::NOT_SIGNALED), | 22 base::WaitableEvent::InitialState::NOT_SIGNALED), |
| 22 controller_(controller) {} | 23 controller_(controller) {} |
| 23 | 24 |
| 24 // Runs on the primary thread. | 25 // Runs on the primary thread. |
| 25 void BackgroundIO::OnIOSignalled() { | 26 void BackgroundIO::OnIOSignalled() { |
| 26 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. | 27 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. |
| 27 tracked_objects::ScopedTracker tracking_profile( | 28 tracked_objects::ScopedTracker tracking_profile( |
| 28 FROM_HERE_WITH_EXPLICIT_FUNCTION("477117 BackgroundIO::OnIOSignalled")); | 29 FROM_HERE_WITH_EXPLICIT_FUNCTION("477117 BackgroundIO::OnIOSignalled")); |
| 29 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), "BackgroundIO::OnIOSignalled"); | 30 TRACE_EVENT0(net::kNetTracingCategory, "BackgroundIO::OnIOSignalled"); |
| 30 if (controller_) | 31 if (controller_) |
| 31 controller_->InvokeCallback(this, false); | 32 controller_->InvokeCallback(this, false); |
| 32 } | 33 } |
| 33 | 34 |
| 34 void BackgroundIO::Cancel() { | 35 void BackgroundIO::Cancel() { |
| 35 // controller_ may be in use from the background thread at this time. | 36 // controller_ may be in use from the background thread at this time. |
| 36 base::AutoLock lock(controller_lock_); | 37 base::AutoLock lock(controller_lock_); |
| 37 DCHECK(controller_); | 38 DCHECK(controller_); |
| 38 controller_ = NULL; | 39 controller_ = NULL; |
| 39 } | 40 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 OnOperationComplete(operation, cancel_task); | 110 OnOperationComplete(operation, cancel_task); |
| 110 } | 111 } |
| 111 | 112 |
| 112 // Runs on the primary thread. | 113 // Runs on the primary thread. |
| 113 void InFlightIO::OnOperationPosted(BackgroundIO* operation) { | 114 void InFlightIO::OnOperationPosted(BackgroundIO* operation) { |
| 114 DCHECK(callback_task_runner_->RunsTasksOnCurrentThread()); | 115 DCHECK(callback_task_runner_->RunsTasksOnCurrentThread()); |
| 115 io_list_.insert(make_scoped_refptr(operation)); | 116 io_list_.insert(make_scoped_refptr(operation)); |
| 116 } | 117 } |
| 117 | 118 |
| 118 } // namespace disk_cache | 119 } // namespace disk_cache |
| OLD | NEW |