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 "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/singleton.h" | 8 #include "base/singleton.h" |
9 #include "net/disk_cache/disk_cache.h" | 9 #include "net/disk_cache/disk_cache.h" |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 memset(this, 0, sizeof(*this)); | 55 memset(this, 0, sizeof(*this)); |
56 context_.handler = Singleton<CompletionHandler>::get(); | 56 context_.handler = Singleton<CompletionHandler>::get(); |
57 context_.overlapped.Offset = static_cast<DWORD>(offset); | 57 context_.overlapped.Offset = static_cast<DWORD>(offset); |
58 file_ = file; | 58 file_ = file; |
59 callback_ = callback; | 59 callback_ = callback; |
60 } | 60 } |
61 | 61 |
62 MyOverlapped::~MyOverlapped() { | 62 MyOverlapped::~MyOverlapped() { |
63 if (delete_buffer_) { | 63 if (delete_buffer_) { |
64 DCHECK(!callback_); | 64 DCHECK(!callback_); |
65 delete buffer_; | 65 // This whole thing could be updated to use IOBuffer, but PostWrite is not |
| 66 // used at the moment. TODO(rvargas): remove or update this code. |
| 67 delete[] reinterpret_cast<const char*>(buffer_); |
66 } | 68 } |
67 } | 69 } |
68 | 70 |
69 } // namespace | 71 } // namespace |
70 | 72 |
71 namespace disk_cache { | 73 namespace disk_cache { |
72 | 74 |
73 // Used from WaitForPendingIO() when the cache is being destroyed. | 75 // Used from WaitForPendingIO() when the cache is being destroyed. |
74 MessageLoopForIO::IOHandler* GetFileIOHandler() { | 76 MessageLoopForIO::IOHandler* GetFileIOHandler() { |
75 return Singleton<CompletionHandler>::get(); | 77 return Singleton<CompletionHandler>::get(); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 HANDLE file = platform_file(); | 264 HANDLE file = platform_file(); |
263 if (!GetFileSizeEx(file, &size)) | 265 if (!GetFileSizeEx(file, &size)) |
264 return 0; | 266 return 0; |
265 if (size.HighPart) | 267 if (size.HighPart) |
266 return ULONG_MAX; | 268 return ULONG_MAX; |
267 | 269 |
268 return static_cast<size_t>(size.LowPart); | 270 return static_cast<size_t>(size.LowPart); |
269 } | 271 } |
270 | 272 |
271 } // namespace disk_cache | 273 } // namespace disk_cache |
OLD | NEW |