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

Side by Side Diff: net/disk_cache/v3/backend_worker.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/v3/backend_work_item.cc ('k') | net/disk_cache/v3/backend_worker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_DISK_CACHE_V3_BACKEND_WORKER_H_
6 #define NET_DISK_CACHE_V3_BACKEND_WORKER_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/files/file_path.h"
13 #include "net/disk_cache/Addr.h"
14 #include "net/disk_cache/block_files.h"
15 #include "net/disk_cache/v3/backend_impl_v3.h"
16
17 #include <map>
18
19 namespace base {
20 class MessageLoopProxy;
21 }
22
23 namespace disk_cache {
24
25 class File;
26 struct InitResult;
27 class MappedFile;
28
29 class BackendImplV3::Worker : public base::RefCountedThreadSafe<Worker> {
30 public:
31 Worker(const base::FilePath& path, base::MessageLoopProxy* main_thread);
32
33 // Construction and destruction helpers.
34 int Init(uint32 flags, scoped_ptr<InitResult>* result);
35 int Restart(uint32 flags, scoped_ptr<InitResult>* result);
36
37 int GrowIndex(uint32 flags, scoped_ptr<InitResult>* result);
38 int GrowFiles(uint32 flags, scoped_ptr<InitResult>* result);
39
40 int Delete(Addr address);
41 int Close(Addr address);
42
43 void OnDoWork(WorkItem* work_item);
44 void DoneWithItem(WorkItem* work_item);
45
46 MappedFile* GetMappedFile(Addr address) {
47 return block_files_->GetFile(address);
48 }
49
50 disk_cache::File* GetBackingFile(Addr address, bool for_write);
51
52 disk_cache::File* GetBackupIndexFile();
53 void CloseBackupIndexFile();
54
55 bool IsValid();
56
57 // Timer notification.
58 void OnTimer();
59
60 private:
61 friend class base::RefCountedThreadSafe<Worker>;
62 typedef std::map<uint32, scoped_refptr<disk_cache::File>> FilesMap;
63
64 ~Worker();
65 void Cleanup(WorkItem* work_item);
66 void CloseFiles();
67
68 disk_cache::File* GetExternalFile(Addr address, bool for_write);
69 base::FilePath GetFileName(Addr address) const;
70
71 bool CreateBackingStore(disk_cache::File* file);
72 bool CreateExtraTable(int extra_len);
73 bool InitBackingStore(bool* file_created);
74 bool LoadIndex(InitResult* init_result);
75 bool CheckIndexFile(MappedFile* file);
76 bool InitStats(IndexHeaderV3* index, InitResult* result);
77 int GrowDone();
78
79 base::FilePath path_;
80 scoped_refptr<base::MessageLoopProxy> main_thread_;
81 scoped_refptr<MappedFile> index_header_;
82 scoped_refptr<MappedFile> main_table_;
83 scoped_refptr<MappedFile> extra_table_;
84 scoped_refptr<MappedFile> index_backup_;
85 scoped_ptr<BlockFiles> block_files_;
86 FilesMap files_;
87 WorkItem* cleanup_work_item_;
88
89 // Valid while growing files:
90 scoped_refptr<MappedFile> big_index_header_;
91 scoped_refptr<MappedFile> big_main_table_;
92 scoped_refptr<MappedFile> big_extra_table_;
93 scoped_refptr<MappedFile> big_extra_temp_table_;
94 scoped_ptr<BlockFiles> big_block_files_;
95
96 bool init_;
97 bool doubling_index_; // The index is being doubled in size;
98 uint32 user_flags_;
99
100 DISALLOW_COPY_AND_ASSIGN(Worker);
101 };
102
103 } // namespace disk_cache
104
105 #endif // NET_DISK_CACHE_V3_BACKEND_WORKER_H_
OLDNEW
« no previous file with comments | « net/disk_cache/v3/backend_work_item.cc ('k') | net/disk_cache/v3/backend_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698