OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/file.h" | 5 #include "net/disk_cache/file.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 public: | 115 public: |
116 InFlightIO() : callback_thread_(MessageLoop::current()) {} | 116 InFlightIO() : callback_thread_(MessageLoop::current()) {} |
117 ~InFlightIO() {} | 117 ~InFlightIO() {} |
118 | 118 |
119 // These methods start an asynchronous operation. The arguments have the same | 119 // These methods start an asynchronous operation. The arguments have the same |
120 // semantics of the File asynchronous operations, with the exception that the | 120 // semantics of the File asynchronous operations, with the exception that the |
121 // operation never finishes synchronously. | 121 // operation never finishes synchronously. |
122 void PostRead(disk_cache::File* file, void* buf, size_t buf_len, | 122 void PostRead(disk_cache::File* file, void* buf, size_t buf_len, |
123 size_t offset, disk_cache::FileIOCallback* callback); | 123 size_t offset, disk_cache::FileIOCallback* callback); |
124 void PostWrite(disk_cache::File* file, const void* buf, size_t buf_len, | 124 void PostWrite(disk_cache::File* file, const void* buf, size_t buf_len, |
125 size_t offset, disk_cache::FileIOCallback* callback, | 125 size_t offset, disk_cache::FileIOCallback* callback, |
126 bool delete_buffer); | 126 bool delete_buffer); |
127 | 127 |
128 // Blocks the current thread until all IO operations tracked by this object | 128 // Blocks the current thread until all IO operations tracked by this object |
129 // complete. | 129 // complete. |
130 void WaitForPendingIO(); | 130 void WaitForPendingIO(); |
131 | 131 |
132 // Called on a worker thread when |operation| completes. | 132 // Called on a worker thread when |operation| completes. |
133 void OnIOComplete(BackgroundIO* operation); | 133 void OnIOComplete(BackgroundIO* operation); |
134 | 134 |
135 // Invokes the users' completion callback at the end of the IO operation. | 135 // Invokes the users' completion callback at the end of the IO operation. |
136 // |cancel_task| is true if the actual task posted to the thread is still | 136 // |cancel_task| is true if the actual task posted to the thread is still |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 return ret; | 370 return ret; |
371 } | 371 } |
372 | 372 |
373 // Static. | 373 // Static. |
374 void File::WaitForPendingIO(int* num_pending_io) { | 374 void File::WaitForPendingIO(int* num_pending_io) { |
375 if (*num_pending_io) | 375 if (*num_pending_io) |
376 Singleton<InFlightIO>::get()->WaitForPendingIO(); | 376 Singleton<InFlightIO>::get()->WaitForPendingIO(); |
377 } | 377 } |
378 | 378 |
379 } // namespace disk_cache | 379 } // namespace disk_cache |
OLD | NEW |