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 | 15 |
16 namespace disk_cache { | 16 namespace disk_cache { |
17 | 17 |
18 BackgroundIO::BackgroundIO(InFlightIO* controller) | 18 BackgroundIO::BackgroundIO(InFlightIO* controller) |
19 : result_(-1), io_completed_(true, false), controller_(controller) { | 19 : result_(-1), |
20 } | 20 io_completed_(base::WaitableEvent::ResetPolicy::MANUAL, |
| 21 base::WaitableEvent::InitialState::NOT_SIGNALED), |
| 22 controller_(controller) {} |
21 | 23 |
22 // Runs on the primary thread. | 24 // Runs on the primary thread. |
23 void BackgroundIO::OnIOSignalled() { | 25 void BackgroundIO::OnIOSignalled() { |
24 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. | 26 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. |
25 tracked_objects::ScopedTracker tracking_profile( | 27 tracked_objects::ScopedTracker tracking_profile( |
26 FROM_HERE_WITH_EXPLICIT_FUNCTION("477117 BackgroundIO::OnIOSignalled")); | 28 FROM_HERE_WITH_EXPLICIT_FUNCTION("477117 BackgroundIO::OnIOSignalled")); |
27 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), "BackgroundIO::OnIOSignalled"); | 29 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), "BackgroundIO::OnIOSignalled"); |
28 if (controller_) | 30 if (controller_) |
29 controller_->InvokeCallback(this, false); | 31 controller_->InvokeCallback(this, false); |
30 } | 32 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 OnOperationComplete(operation, cancel_task); | 109 OnOperationComplete(operation, cancel_task); |
108 } | 110 } |
109 | 111 |
110 // Runs on the primary thread. | 112 // Runs on the primary thread. |
111 void InFlightIO::OnOperationPosted(BackgroundIO* operation) { | 113 void InFlightIO::OnOperationPosted(BackgroundIO* operation) { |
112 DCHECK(callback_task_runner_->RunsTasksOnCurrentThread()); | 114 DCHECK(callback_task_runner_->RunsTasksOnCurrentThread()); |
113 io_list_.insert(make_scoped_refptr(operation)); | 115 io_list_.insert(make_scoped_refptr(operation)); |
114 } | 116 } |
115 | 117 |
116 } // namespace disk_cache | 118 } // namespace disk_cache |
OLD | NEW |