Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: net/disk_cache/mapped_file.h

Issue 15203004: Disk cache: Reference CL for the implementation of file format version 3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: IndexTable review Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/in_flight_io.cc ('k') | net/disk_cache/mapped_file_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "net/disk_cache/disk_format.h"
12 #include "net/disk_cache/file.h" 11 #include "net/disk_cache/file.h"
13 #include "net/disk_cache/file_block.h" 12 #include "net/disk_cache/file_block.h"
14 13
15 namespace base { 14 namespace base {
16 class FilePath; 15 class FilePath;
17 } 16 }
18 17
19 namespace disk_cache { 18 namespace disk_cache {
20 19
21 // This class implements a memory mapped file used to access block-files. The 20 // This class implements a memory mapped file used to access block-files. The
22 // idea is that the header and bitmap will be memory mapped all the time, and 21 // idea is that the header and bitmap will be memory mapped all the time, and
23 // the actual data for the blocks will be access asynchronously (most of the 22 // the actual data for the blocks will be access asynchronously (most of the
24 // time). 23 // time).
25 class NET_EXPORT_PRIVATE MappedFile : public File { 24 class NET_EXPORT_PRIVATE MappedFile : public File {
26 public: 25 public:
27 MappedFile() : File(true), init_(false) {} 26 MappedFile() : File(true), init_(false) {}
28 27
29 // 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
30 // 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
31 // will be mapped in memory. 30 // will be mapped in memory.
32 void* Init(const base::FilePath& name, size_t size); 31 void* Init(const base::FilePath& name, size_t size);
33 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
34 void* buffer() const { 38 void* buffer() const {
35 return buffer_; 39 return buffer_;
36 } 40 }
37 41
38 // Loads or stores a given block from the backing file (synchronously). 42 // Loads or stores a given block from the backing file (synchronously).
39 bool Load(const FileBlock* block); 43 bool Load(const FileBlock* block);
40 bool Store(const FileBlock* block); 44 bool Store(const FileBlock* block);
41 45
46 // Asynchronous versions of Load/Store, following the semantics of File::Read
47 // and File::Write.
48 bool Load(const FileBlock* block, FileIOCallback* callback, bool* completed);
49 bool Store(const FileBlock* block, FileIOCallback* callback, bool* completed);
50
42 // Flush the memory-mapped section to disk (synchronously). 51 // Flush the memory-mapped section to disk (synchronously).
43 void Flush(); 52 void Flush();
44 53
45 private: 54 private:
46 virtual ~MappedFile(); 55 virtual ~MappedFile();
47 56
48 bool init_; 57 bool init_;
49 #if defined(OS_WIN) 58 #if defined(OS_WIN)
50 HANDLE section_; 59 HANDLE section_;
51 #endif 60 #endif
(...skipping 13 matching lines...) Expand all
65 ~ScopedFlush() { 74 ~ScopedFlush() {
66 file_->Flush(); 75 file_->Flush();
67 } 76 }
68 private: 77 private:
69 MappedFile* file_; 78 MappedFile* file_;
70 }; 79 };
71 80
72 } // namespace disk_cache 81 } // namespace disk_cache
73 82
74 #endif // NET_DISK_CACHE_MAPPED_FILE_H_ 83 #endif // NET_DISK_CACHE_MAPPED_FILE_H_
OLDNEW
« no previous file with comments | « net/disk_cache/in_flight_io.cc ('k') | net/disk_cache/mapped_file_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698