| 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 | |
| 76 protected: | 73 protected: |
| 77 virtual ~File(); | 74 virtual ~File(); |
| 78 | 75 |
| 76 private: |
| 79 // Performs the actual asynchronous write. If notify is set and there is no | 77 // Performs the actual asynchronous write. If notify is set and there is no |
| 80 // callback, the call will be re-synchronized. | 78 // callback, the call will be re-synchronized. |
| 81 bool AsyncWrite(const void* buffer, size_t buffer_len, size_t offset, | 79 bool AsyncWrite(const void* buffer, size_t buffer_len, size_t offset, |
| 82 FileIOCallback* callback, bool* completed); | 80 FileIOCallback* callback, bool* completed); |
| 83 | 81 |
| 84 private: | 82 // Infrastructure for async IO. |
| 83 int DoRead(void* buffer, size_t buffer_len, size_t offset); |
| 84 int DoWrite(const void* buffer, size_t buffer_len, size_t offset); |
| 85 void OnOperationComplete(FileIOCallback* callback, int result); |
| 86 |
| 85 bool init_; | 87 bool init_; |
| 86 bool mixed_; | 88 bool mixed_; |
| 87 base::PlatformFile platform_file_; // Regular, asynchronous IO handle. | 89 base::PlatformFile platform_file_; // Regular, asynchronous IO handle. |
| 88 base::PlatformFile sync_platform_file_; // Synchronous IO handle. | 90 base::PlatformFile sync_platform_file_; // Synchronous IO handle. |
| 89 | 91 |
| 90 DISALLOW_COPY_AND_ASSIGN(File); | 92 DISALLOW_COPY_AND_ASSIGN(File); |
| 91 }; | 93 }; |
| 92 | 94 |
| 93 } // namespace disk_cache | 95 } // namespace disk_cache |
| 94 | 96 |
| 95 #endif // NET_DISK_CACHE_FILE_H_ | 97 #endif // NET_DISK_CACHE_FILE_H_ |
| OLD | NEW |