| 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_BLOCKFILE_MAPPED_FILE_H_ | 7 #ifndef NET_DISK_CACHE_BLOCKFILE_MAPPED_FILE_H_ |
| 8 #define NET_DISK_CACHE_BLOCKFILE_MAPPED_FILE_H_ | 8 #define NET_DISK_CACHE_BLOCKFILE_MAPPED_FILE_H_ |
| 9 | 9 |
| 10 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 bool Store(const FileBlock* block, FileIOCallback* callback, bool* completed); | 44 bool Store(const FileBlock* block, FileIOCallback* callback, bool* completed); |
| 45 | 45 |
| 46 // Flush the memory-mapped section to disk (synchronously). | 46 // Flush the memory-mapped section to disk (synchronously). |
| 47 void Flush(); | 47 void Flush(); |
| 48 | 48 |
| 49 // Heats up the file system cache and make sure the file is fully | 49 // Heats up the file system cache and make sure the file is fully |
| 50 // readable (synchronously). | 50 // readable (synchronously). |
| 51 bool Preload(); | 51 bool Preload(); |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 virtual ~MappedFile(); | 54 ~MappedFile() override; |
| 55 | 55 |
| 56 bool init_; | 56 bool init_; |
| 57 #if defined(OS_WIN) | 57 #if defined(OS_WIN) |
| 58 HANDLE section_; | 58 HANDLE section_; |
| 59 #endif | 59 #endif |
| 60 void* buffer_; // Address of the memory mapped buffer. | 60 void* buffer_; // Address of the memory mapped buffer. |
| 61 size_t view_size_; // Size of the memory pointed by buffer_. | 61 size_t view_size_; // Size of the memory pointed by buffer_. |
| 62 #if defined(POSIX_AVOID_MMAP) | 62 #if defined(POSIX_AVOID_MMAP) |
| 63 void* snapshot_; // Copy of the buffer taken when it was last flushed. | 63 void* snapshot_; // Copy of the buffer taken when it was last flushed. |
| 64 #endif | 64 #endif |
| 65 | 65 |
| 66 DISALLOW_COPY_AND_ASSIGN(MappedFile); | 66 DISALLOW_COPY_AND_ASSIGN(MappedFile); |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 // Helper class for calling Flush() on exit from the current scope. | 69 // Helper class for calling Flush() on exit from the current scope. |
| 70 class ScopedFlush { | 70 class ScopedFlush { |
| 71 public: | 71 public: |
| 72 explicit ScopedFlush(MappedFile* file) : file_(file) {} | 72 explicit ScopedFlush(MappedFile* file) : file_(file) {} |
| 73 ~ScopedFlush() { | 73 ~ScopedFlush() { |
| 74 file_->Flush(); | 74 file_->Flush(); |
| 75 } | 75 } |
| 76 private: | 76 private: |
| 77 MappedFile* file_; | 77 MappedFile* file_; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 } // namespace disk_cache | 80 } // namespace disk_cache |
| 81 | 81 |
| 82 #endif // NET_DISK_CACHE_BLOCKFILE_MAPPED_FILE_H_ | 82 #endif // NET_DISK_CACHE_BLOCKFILE_MAPPED_FILE_H_ |
| OLD | NEW |