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 // See net/disk_cache/disk_cache.h for the public interface of the cache. | 5 // See net/disk_cache/disk_cache.h for the public interface of the cache. |
6 | 6 |
7 #ifndef NET_DISK_CACHE_FILE_H_ | 7 #ifndef NET_DISK_CACHE_FILE_H_ |
8 #define NET_DISK_CACHE_FILE_H_ | 8 #define NET_DISK_CACHE_FILE_H_ |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 FileIOCallback* callback, bool* completed); | 63 FileIOCallback* callback, bool* completed); |
64 | 64 |
65 // Sets the file's length. The file is truncated or extended with zeros to | 65 // Sets the file's length. The file is truncated or extended with zeros to |
66 // the new length. | 66 // the new length. |
67 bool SetLength(size_t length); | 67 bool SetLength(size_t length); |
68 size_t GetLength(); | 68 size_t GetLength(); |
69 | 69 |
70 // Blocks until |num_pending_io| IO operations complete. | 70 // Blocks until |num_pending_io| IO operations complete. |
71 static void WaitForPendingIO(int* num_pending_io); | 71 static void WaitForPendingIO(int* num_pending_io); |
72 | 72 |
| 73 // Drops current pending operations without waiting for them to complete. |
| 74 static void DropPendingIO(); |
| 75 |
73 protected: | 76 protected: |
74 virtual ~File(); | 77 virtual ~File(); |
75 | 78 |
76 private: | 79 private: |
77 // Performs the actual asynchronous write. If notify is set and there is no | 80 // Performs the actual asynchronous write. If notify is set and there is no |
78 // callback, the call will be re-synchronized. | 81 // callback, the call will be re-synchronized. |
79 bool AsyncWrite(const void* buffer, size_t buffer_len, size_t offset, | 82 bool AsyncWrite(const void* buffer, size_t buffer_len, size_t offset, |
80 FileIOCallback* callback, bool* completed); | 83 FileIOCallback* callback, bool* completed); |
81 | 84 |
82 // Infrastructure for async IO. | 85 // Infrastructure for async IO. |
83 int DoRead(void* buffer, size_t buffer_len, size_t offset); | 86 int DoRead(void* buffer, size_t buffer_len, size_t offset); |
84 int DoWrite(const void* buffer, size_t buffer_len, size_t offset); | 87 int DoWrite(const void* buffer, size_t buffer_len, size_t offset); |
85 void OnOperationComplete(FileIOCallback* callback, int result); | 88 void OnOperationComplete(FileIOCallback* callback, int result); |
86 | 89 |
87 bool init_; | 90 bool init_; |
88 bool mixed_; | 91 bool mixed_; |
89 base::PlatformFile platform_file_; // Regular, asynchronous IO handle. | 92 base::PlatformFile platform_file_; // Regular, asynchronous IO handle. |
90 base::PlatformFile sync_platform_file_; // Synchronous IO handle. | 93 base::PlatformFile sync_platform_file_; // Synchronous IO handle. |
91 | 94 |
92 DISALLOW_COPY_AND_ASSIGN(File); | 95 DISALLOW_COPY_AND_ASSIGN(File); |
93 }; | 96 }; |
94 | 97 |
95 } // namespace disk_cache | 98 } // namespace disk_cache |
96 | 99 |
97 #endif // NET_DISK_CACHE_FILE_H_ | 100 #endif // NET_DISK_CACHE_FILE_H_ |
OLD | NEW |