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