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/file.h" | 5 #include "net/disk_cache/blockfile/file.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 static_assert(offsetof(MyOverlapped, context_) == 0, | 32 static_assert(offsetof(MyOverlapped, context_) == 0, |
33 "should start with overlapped"); | 33 "should start with overlapped"); |
34 | 34 |
35 // Helper class to handle the IO completion notifications from the message loop. | 35 // Helper class to handle the IO completion notifications from the message loop. |
36 class CompletionHandler : public base::MessageLoopForIO::IOHandler { | 36 class CompletionHandler : public base::MessageLoopForIO::IOHandler { |
37 void OnIOCompleted(base::MessageLoopForIO::IOContext* context, | 37 void OnIOCompleted(base::MessageLoopForIO::IOContext* context, |
38 DWORD actual_bytes, | 38 DWORD actual_bytes, |
39 DWORD error) override; | 39 DWORD error) override; |
40 }; | 40 }; |
41 | 41 |
42 static base::LazyInstance<CompletionHandler> g_completion_handler = | 42 static base::LazyInstance<CompletionHandler>::DestructorAtExit |
43 LAZY_INSTANCE_INITIALIZER; | 43 g_completion_handler = LAZY_INSTANCE_INITIALIZER; |
44 | 44 |
45 void CompletionHandler::OnIOCompleted( | 45 void CompletionHandler::OnIOCompleted( |
46 base::MessageLoopForIO::IOContext* context, | 46 base::MessageLoopForIO::IOContext* context, |
47 DWORD actual_bytes, | 47 DWORD actual_bytes, |
48 DWORD error) { | 48 DWORD error) { |
49 MyOverlapped* data = reinterpret_cast<MyOverlapped*>(context); | 49 MyOverlapped* data = reinterpret_cast<MyOverlapped*>(context); |
50 | 50 |
51 if (error) { | 51 if (error) { |
52 DCHECK(!actual_bytes); | 52 DCHECK(!actual_bytes); |
53 actual_bytes = static_cast<DWORD>(net::ERR_CACHE_READ_FAILURE); | 53 actual_bytes = static_cast<DWORD>(net::ERR_CACHE_READ_FAILURE); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 base::MessageLoopForIO::IOHandler* handler = g_completion_handler.Pointer(); | 247 base::MessageLoopForIO::IOHandler* handler = g_completion_handler.Pointer(); |
248 base::MessageLoopForIO::current()->WaitForIOCompletion(100, handler); | 248 base::MessageLoopForIO::current()->WaitForIOCompletion(100, handler); |
249 } | 249 } |
250 } | 250 } |
251 | 251 |
252 // Static. | 252 // Static. |
253 void File::DropPendingIO() { | 253 void File::DropPendingIO() { |
254 } | 254 } |
255 | 255 |
256 } // namespace disk_cache | 256 } // namespace disk_cache |
OLD | NEW |