summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/file_win.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/disk_cache/file_win.cc')
-rw-r--r--net/disk_cache/file_win.cc25
1 files changed, 18 insertions, 7 deletions
diff --git a/net/disk_cache/file_win.cc b/net/disk_cache/file_win.cc
index c2e00b7..b341caf 100644
--- a/net/disk_cache/file_win.cc
+++ b/net/disk_cache/file_win.cc
@@ -72,11 +72,6 @@ MyOverlapped::~MyOverlapped() {
namespace disk_cache {
-// Used from WaitForPendingIO() when the cache is being destroyed.
-MessageLoopForIO::IOHandler* GetFileIOHandler() {
- return Singleton<CompletionHandler>::get();
-}
-
File::File(base::PlatformFile file)
: init_(true), mixed_(true), platform_file_(INVALID_HANDLE_VALUE),
sync_platform_file_(file) {
@@ -171,8 +166,11 @@ bool File::Write(const void* buffer, size_t buffer_len, size_t offset) {
bool File::Read(void* buffer, size_t buffer_len, size_t offset,
FileIOCallback* callback, bool* completed) {
DCHECK(init_);
- if (!callback)
+ if (!callback) {
+ if (completed)
+ *completed = true;
return Read(buffer, buffer_len, offset);
+ }
if (buffer_len > ULONG_MAX || offset > ULONG_MAX)
return false;
@@ -200,8 +198,11 @@ bool File::Read(void* buffer, size_t buffer_len, size_t offset,
bool File::Write(const void* buffer, size_t buffer_len, size_t offset,
FileIOCallback* callback, bool* completed) {
DCHECK(init_);
- if (!callback)
+ if (!callback) {
+ if (completed)
+ *completed = true;
return Write(buffer, buffer_len, offset);
+ }
return AsyncWrite(buffer, buffer_len, offset, true, callback, completed);
}
@@ -270,4 +271,14 @@ size_t File::GetLength() {
return static_cast<size_t>(size.LowPart);
}
+// Static.
+void File::WaitForPendingIO(int* num_pending_io) {
+ while (*num_pending_io) {
+ // Asynchronous IO operations may be in flight and the completion may end
+ // up calling us back so let's wait for them.
+ MessageLoopForIO::IOHandler* handler = Singleton<CompletionHandler>::get();
+ MessageLoopForIO::current()->WaitForIOCompletion(100, handler);
+ }
+}
+
} // namespace disk_cache