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 // 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 #pragma once | 9 #pragma once |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 bool Read(void* buffer, size_t buffer_len, size_t offset); | 54 bool Read(void* buffer, size_t buffer_len, size_t offset); |
55 bool Write(const void* buffer, size_t buffer_len, size_t offset); | 55 bool Write(const void* buffer, size_t buffer_len, size_t offset); |
56 | 56 |
57 // Performs asynchronous IO. callback will be called when the IO completes, | 57 // Performs asynchronous IO. callback will be called when the IO completes, |
58 // as an APC on the thread that queued the operation. | 58 // as an APC on the thread that queued the operation. |
59 bool Read(void* buffer, size_t buffer_len, size_t offset, | 59 bool Read(void* buffer, size_t buffer_len, size_t offset, |
60 FileIOCallback* callback, bool* completed); | 60 FileIOCallback* callback, bool* completed); |
61 bool Write(const void* buffer, size_t buffer_len, size_t offset, | 61 bool Write(const void* buffer, size_t buffer_len, size_t offset, |
62 FileIOCallback* callback, bool* completed); | 62 FileIOCallback* callback, bool* completed); |
63 | 63 |
64 // Performs asynchronous writes, but doesn't notify when done. Automatically | |
65 // deletes buffer when done. | |
66 bool PostWrite(const void* buffer, size_t buffer_len, size_t offset); | |
67 | |
68 // Sets the file's length. The file is truncated or extended with zeros to | 64 // Sets the file's length. The file is truncated or extended with zeros to |
69 // the new length. | 65 // the new length. |
70 bool SetLength(size_t length); | 66 bool SetLength(size_t length); |
71 size_t GetLength(); | 67 size_t GetLength(); |
72 | 68 |
73 // Blocks until |num_pending_io| IO operations complete. | 69 // Blocks until |num_pending_io| IO operations complete. |
74 static void WaitForPendingIO(int* num_pending_io); | 70 static void WaitForPendingIO(int* num_pending_io); |
75 | 71 |
76 protected: | 72 protected: |
77 virtual ~File(); | 73 virtual ~File(); |
78 | 74 |
79 // Performs the actual asynchronous write. If notify is set and there is no | 75 // Performs the actual asynchronous write. If notify is set and there is no |
80 // callback, the call will be re-synchronized. | 76 // callback, the call will be re-synchronized. |
81 bool AsyncWrite(const void* buffer, size_t buffer_len, size_t offset, | 77 bool AsyncWrite(const void* buffer, size_t buffer_len, size_t offset, |
82 bool notify, FileIOCallback* callback, bool* completed); | 78 FileIOCallback* callback, bool* completed); |
83 | 79 |
84 private: | 80 private: |
85 bool init_; | 81 bool init_; |
86 bool mixed_; | 82 bool mixed_; |
87 base::PlatformFile platform_file_; // Regular, asynchronous IO handle. | 83 base::PlatformFile platform_file_; // Regular, asynchronous IO handle. |
88 base::PlatformFile sync_platform_file_; // Synchronous IO handle. | 84 base::PlatformFile sync_platform_file_; // Synchronous IO handle. |
89 | 85 |
90 DISALLOW_COPY_AND_ASSIGN(File); | 86 DISALLOW_COPY_AND_ASSIGN(File); |
91 }; | 87 }; |
92 | 88 |
93 } // namespace disk_cache | 89 } // namespace disk_cache |
94 | 90 |
95 #endif // NET_DISK_CACHE_FILE_H_ | 91 #endif // NET_DISK_CACHE_FILE_H_ |
OLD | NEW |