1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// found in the LICENSE file. 4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// See net/disk_cache/disk_cache.h for the public interface of the cache. 6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#ifndef NET_DISK_CACHE_BLOCKFILE_BACKEND_WORKER_V3_H_ 8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#define NET_DISK_CACHE_BLOCKFILE_BACKEND_WORKER_V3_H_ 9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 107d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "base/containers/hash_tables.h" 11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/files/file_path.h" 1203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "base/memory/ref_counted.h" 13effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "net/disk_cache/blockfile/addr.h" 14effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "net/disk_cache/blockfile/backend_impl_v3.h" 15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "net/disk_cache/blockfile/block_files.h" 16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 1703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)namespace base { 1803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)class SingleThreadTaskRunner; 1903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)} // namespace base 2003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) 21868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace disk_cache { 22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 23effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochclass BackendImplV3::Worker : public base::RefCountedThreadSafe<Worker> { 24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) public: 2503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) Worker(const base::FilePath& path, 2603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const scoped_refptr<base::SingleThreadTaskRunner>& main_thread); 27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Performs general initialization for this current instance of the cache. 29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int Init(const CompletionCallback& callback); 30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) private: 32effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch friend class base::RefCountedThreadSafe<Worker>; 33effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch 34effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch ~Worker(); 35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void CleanupCache(); 36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Returns the full name for an external storage file. 38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) base::FilePath GetFileName(Addr address) const; 39868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 40868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Creates a new backing file for the cache index. 41868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool CreateBackingStore(disk_cache::File* file); 42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool InitBackingStore(bool* file_created); 43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 44868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Performs basic checks on the index file. Returns false on failure. 45868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool CheckIndex(); 46868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 47868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) base::FilePath path_; // Path to the folder used as backing storage. 48868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) BlockFiles block_files_; // Set of files used to store all data. 49868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool init_; // controls the initialization of the system. 50868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 51effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch DISALLOW_COPY_AND_ASSIGN(Worker); 52868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}; 53868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 54868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} // namespace disk_cache 55868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 56a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#endif // NET_DISK_CACHE_BLOCKFILE_BACKEND_WORKER_V3_H_ 57