OLD | NEW |
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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/in_flight_io.h" | 5 #include "net/disk_cache/in_flight_io.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace disk_cache { | 9 namespace disk_cache { |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 BackgroundIO::~BackgroundIO() {} | 26 BackgroundIO::~BackgroundIO() {} |
27 | 27 |
28 // Runs on the background thread. | 28 // Runs on the background thread. |
29 void BackgroundIO::NotifyController() { | 29 void BackgroundIO::NotifyController() { |
30 controller_->OnIOComplete(this); | 30 controller_->OnIOComplete(this); |
31 } | 31 } |
32 | 32 |
33 // --------------------------------------------------------------------------- | 33 // --------------------------------------------------------------------------- |
34 | 34 |
35 InFlightIO::InFlightIO() | 35 InFlightIO::InFlightIO() |
36 : callback_thread_(base::MessageLoopProxy::CreateForCurrentThread()), | 36 : callback_thread_(base::MessageLoopProxy::current()), |
37 running_(false), single_thread_(false) { | 37 running_(false), single_thread_(false) { |
38 } | 38 } |
39 | 39 |
40 InFlightIO::~InFlightIO() { | 40 InFlightIO::~InFlightIO() { |
41 } | 41 } |
42 | 42 |
43 void InFlightIO::WaitForPendingIO() { | 43 void InFlightIO::WaitForPendingIO() { |
44 while (!io_list_.empty()) { | 44 while (!io_list_.empty()) { |
45 // Block the current thread until all pending IO completes. | 45 // Block the current thread until all pending IO completes. |
46 IOList::iterator it = io_list_.begin(); | 46 IOList::iterator it = io_list_.begin(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 OnOperationComplete(operation, cancel_task); | 78 OnOperationComplete(operation, cancel_task); |
79 } | 79 } |
80 | 80 |
81 // Runs on the primary thread. | 81 // Runs on the primary thread. |
82 void InFlightIO::OnOperationPosted(BackgroundIO* operation) { | 82 void InFlightIO::OnOperationPosted(BackgroundIO* operation) { |
83 DCHECK(callback_thread_->BelongsToCurrentThread()); | 83 DCHECK(callback_thread_->BelongsToCurrentThread()); |
84 io_list_.insert(make_scoped_refptr(operation)); | 84 io_list_.insert(make_scoped_refptr(operation)); |
85 } | 85 } |
86 | 86 |
87 } // namespace disk_cache | 87 } // namespace disk_cache |
OLD | NEW |