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