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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // Runs on the primary thread. | 67 // Runs on the primary thread. |
68 void InFlightIO::InvokeCallback(BackgroundIO* operation, bool cancel_task) { | 68 void InFlightIO::InvokeCallback(BackgroundIO* operation, bool cancel_task) { |
69 operation->io_completed()->Wait(); | 69 operation->io_completed()->Wait(); |
70 | 70 |
71 if (cancel_task) | 71 if (cancel_task) |
72 operation->Cancel(); | 72 operation->Cancel(); |
73 | 73 |
74 // Make sure that we remove the operation from the list before invoking the | 74 // Make sure that we remove the operation from the list before invoking the |
75 // callback (so that a subsequent cancel does not invoke the callback again). | 75 // callback (so that a subsequent cancel does not invoke the callback again). |
76 DCHECK(io_list_.find(operation) != io_list_.end()); | 76 DCHECK(io_list_.find(operation) != io_list_.end()); |
77 io_list_.erase(operation); | 77 io_list_.erase(make_scoped_refptr(operation)); |
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(operation); | 84 io_list_.insert(make_scoped_refptr(operation)); |
85 } | 85 } |
86 | 86 |
87 } // namespace disk_cache | 87 } // namespace disk_cache |
OLD | NEW |