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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 bool Read(void* buffer, size_t buffer_len, size_t offset, | 60 bool Read(void* buffer, size_t buffer_len, size_t offset, |
61 FileIOCallback* callback, bool* completed); | 61 FileIOCallback* callback, bool* completed); |
62 bool Write(const void* buffer, size_t buffer_len, size_t offset, | 62 bool Write(const void* buffer, size_t buffer_len, size_t offset, |
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 void set_force_creation() { force_creation_ = true; } |
| 71 |
70 // Blocks until |num_pending_io| IO operations complete. | 72 // Blocks until |num_pending_io| IO operations complete. |
71 static void WaitForPendingIO(int* num_pending_io); | 73 static void WaitForPendingIO(int* num_pending_io); |
72 | 74 |
73 protected: | 75 protected: |
74 virtual ~File(); | 76 virtual ~File(); |
75 | 77 |
76 private: | 78 private: |
77 // Performs the actual asynchronous write. If notify is set and there is no | 79 // Performs the actual asynchronous write. If notify is set and there is no |
78 // callback, the call will be re-synchronized. | 80 // callback, the call will be re-synchronized. |
79 bool AsyncWrite(const void* buffer, size_t buffer_len, size_t offset, | 81 bool AsyncWrite(const void* buffer, size_t buffer_len, size_t offset, |
80 FileIOCallback* callback, bool* completed); | 82 FileIOCallback* callback, bool* completed); |
81 | 83 |
82 // Infrastructure for async IO. | 84 // Infrastructure for async IO. |
83 int DoRead(void* buffer, size_t buffer_len, size_t offset); | 85 int DoRead(void* buffer, size_t buffer_len, size_t offset); |
84 int DoWrite(const void* buffer, size_t buffer_len, size_t offset); | 86 int DoWrite(const void* buffer, size_t buffer_len, size_t offset); |
85 void OnOperationComplete(FileIOCallback* callback, int result); | 87 void OnOperationComplete(FileIOCallback* callback, int result); |
86 | 88 |
87 bool init_; | 89 bool init_; |
88 bool mixed_; | 90 bool mixed_; |
| 91 bool force_creation_; |
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 |