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

Unified 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, 1 month 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/v3/backend_worker.h
===================================================================
--- net/disk_cache/v3/backend_worker.h (revision 0)
+++ net/disk_cache/v3/backend_worker.h (revision 0)
@@ -0,0 +1,105 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_DISK_CACHE_V3_BACKEND_WORKER_H_
+#define NET_DISK_CACHE_V3_BACKEND_WORKER_H_
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/files/file_path.h"
+#include "net/disk_cache/Addr.h"
+#include "net/disk_cache/block_files.h"
+#include "net/disk_cache/v3/backend_impl_v3.h"
+
+#include <map>
+
+namespace base {
+class MessageLoopProxy;
+}
+
+namespace disk_cache {
+
+class File;
+struct InitResult;
+class MappedFile;
+
+class BackendImplV3::Worker : public base::RefCountedThreadSafe<Worker> {
+ public:
+ Worker(const base::FilePath& path, base::MessageLoopProxy* main_thread);
+
+ // Construction and destruction helpers.
+ int Init(uint32 flags, scoped_ptr<InitResult>* result);
+ int Restart(uint32 flags, scoped_ptr<InitResult>* result);
+
+ int GrowIndex(uint32 flags, scoped_ptr<InitResult>* result);
+ int GrowFiles(uint32 flags, scoped_ptr<InitResult>* result);
+
+ int Delete(Addr address);
+ int Close(Addr address);
+
+ void OnDoWork(WorkItem* work_item);
+ void DoneWithItem(WorkItem* work_item);
+
+ MappedFile* GetMappedFile(Addr address) {
+ return block_files_->GetFile(address);
+ }
+
+ disk_cache::File* GetBackingFile(Addr address, bool for_write);
+
+ disk_cache::File* GetBackupIndexFile();
+ void CloseBackupIndexFile();
+
+ bool IsValid();
+
+ // Timer notification.
+ void OnTimer();
+
+ private:
+ friend class base::RefCountedThreadSafe<Worker>;
+ typedef std::map<uint32, scoped_refptr<disk_cache::File>> FilesMap;
+
+ ~Worker();
+ void Cleanup(WorkItem* work_item);
+ void CloseFiles();
+
+ disk_cache::File* GetExternalFile(Addr address, bool for_write);
+ base::FilePath GetFileName(Addr address) const;
+
+ bool CreateBackingStore(disk_cache::File* file);
+ bool CreateExtraTable(int extra_len);
+ bool InitBackingStore(bool* file_created);
+ bool LoadIndex(InitResult* init_result);
+ bool CheckIndexFile(MappedFile* file);
+ bool InitStats(IndexHeaderV3* index, InitResult* result);
+ int GrowDone();
+
+ base::FilePath path_;
+ scoped_refptr<base::MessageLoopProxy> main_thread_;
+ scoped_refptr<MappedFile> index_header_;
+ scoped_refptr<MappedFile> main_table_;
+ scoped_refptr<MappedFile> extra_table_;
+ scoped_refptr<MappedFile> index_backup_;
+ scoped_ptr<BlockFiles> block_files_;
+ FilesMap files_;
+ WorkItem* cleanup_work_item_;
+
+ // Valid while growing files:
+ scoped_refptr<MappedFile> big_index_header_;
+ scoped_refptr<MappedFile> big_main_table_;
+ scoped_refptr<MappedFile> big_extra_table_;
+ scoped_refptr<MappedFile> big_extra_temp_table_;
+ scoped_ptr<BlockFiles> big_block_files_;
+
+ bool init_;
+ bool doubling_index_; // The index is being doubled in size;
+ uint32 user_flags_;
+
+ DISALLOW_COPY_AND_ASSIGN(Worker);
+};
+
+} // namespace disk_cache
+
+#endif // NET_DISK_CACHE_V3_BACKEND_WORKER_H_
Property changes on: net\disk_cache\v3\backend_worker.h
___________________________________________________________________
Added: svn:eol-style
+ LF
« 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