backend_worker_v3.h revision effb81e5f8246d0db0270817048dc992db66e9fb
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// See net/disk_cache/disk_cache.h for the public interface of the cache. 6 7#ifndef NET_DISK_CACHE_BLOCKFILE_BACKEND_WORKER_V3_H_ 8#define NET_DISK_CACHE_BLOCKFILE_BACKEND_WORKER_V3_H_ 9 10#include "base/containers/hash_tables.h" 11#include "base/files/file_path.h" 12#include "net/disk_cache/blockfile/addr.h" 13#include "net/disk_cache/blockfile/backend_impl_v3.h" 14#include "net/disk_cache/blockfile/block_files.h" 15 16namespace disk_cache { 17 18class BackendImplV3::Worker : public base::RefCountedThreadSafe<Worker> { 19 public: 20 Worker(const base::FilePath& path, base::MessageLoopProxy* main_thread); 21 22 // Performs general initialization for this current instance of the cache. 23 int Init(const CompletionCallback& callback); 24 25 private: 26 friend class base::RefCountedThreadSafe<Worker>; 27 28 ~Worker(); 29 void CleanupCache(); 30 31 // Returns the full name for an external storage file. 32 base::FilePath GetFileName(Addr address) const; 33 34 // Creates a new backing file for the cache index. 35 bool CreateBackingStore(disk_cache::File* file); 36 bool InitBackingStore(bool* file_created); 37 38 // Performs basic checks on the index file. Returns false on failure. 39 bool CheckIndex(); 40 41 base::FilePath path_; // Path to the folder used as backing storage. 42 BlockFiles block_files_; // Set of files used to store all data. 43 bool init_; // controls the initialization of the system. 44 45 DISALLOW_COPY_AND_ASSIGN(Worker); 46}; 47 48} // namespace disk_cache 49 50#endif // NET_DISK_CACHE_BLOCKFILE_BACKEND_WORKER_V3_H_ 51