| 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_MAPPED_FILE_H_ | 7 #ifndef NET_DISK_CACHE_MAPPED_FILE_H_ |
| 8 #define NET_DISK_CACHE_MAPPED_FILE_H_ | 8 #define NET_DISK_CACHE_MAPPED_FILE_H_ |
| 9 | 9 |
| 10 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // time). | 23 // time). |
| 24 class NET_EXPORT_PRIVATE MappedFile : public File { | 24 class NET_EXPORT_PRIVATE MappedFile : public File { |
| 25 public: | 25 public: |
| 26 MappedFile() : File(true), init_(false) {} | 26 MappedFile() : File(true), init_(false) {} |
| 27 | 27 |
| 28 // Performs object initialization. name is the file to use, and size is the | 28 // Performs object initialization. name is the file to use, and size is the |
| 29 // amount of data to memory map from the file. If size is 0, the whole file | 29 // amount of data to memory map from the file. If size is 0, the whole file |
| 30 // will be mapped in memory. | 30 // will be mapped in memory. |
| 31 void* Init(const base::FilePath& name, size_t size); | 31 void* Init(const base::FilePath& name, size_t size); |
| 32 | 32 |
| 33 // Performs object initialization without actually mapping any portion of the |
| 34 // file. It assumes that the bitmap and header (of the related block file) are |
| 35 // mapped somewhere else. |
| 36 bool InitNoMap(const base::FilePath& name); |
| 37 |
| 33 void* buffer() const { | 38 void* buffer() const { |
| 34 return buffer_; | 39 return buffer_; |
| 35 } | 40 } |
| 36 | 41 |
| 37 // Loads or stores a given block from the backing file (synchronously). | 42 // Loads or stores a given block from the backing file (synchronously). |
| 38 bool Load(const FileBlock* block); | 43 bool Load(const FileBlock* block); |
| 39 bool Store(const FileBlock* block); | 44 bool Store(const FileBlock* block); |
| 40 | 45 |
| 41 // Asynchronous versions of Load/Store, following the semantics of File::Read | 46 // Asynchronous versions of Load/Store, following the semantics of File::Read |
| 42 // and File::Write. | 47 // and File::Write. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 69 ~ScopedFlush() { | 74 ~ScopedFlush() { |
| 70 file_->Flush(); | 75 file_->Flush(); |
| 71 } | 76 } |
| 72 private: | 77 private: |
| 73 MappedFile* file_; | 78 MappedFile* file_; |
| 74 }; | 79 }; |
| 75 | 80 |
| 76 } // namespace disk_cache | 81 } // namespace disk_cache |
| 77 | 82 |
| 78 #endif // NET_DISK_CACHE_MAPPED_FILE_H_ | 83 #endif // NET_DISK_CACHE_MAPPED_FILE_H_ |
| OLD | NEW |