Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / net / disk_cache / blockfile / backend_worker_v3.h
blob6874228477c06d33c816f17946bc264ac797b2ee
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.
5 // See net/disk_cache/disk_cache.h for the public interface of the cache.
7 #ifndef NET_DISK_CACHE_BLOCKFILE_BACKEND_WORKER_V3_H_
8 #define NET_DISK_CACHE_BLOCKFILE_BACKEND_WORKER_V3_H_
10 #include "base/containers/hash_tables.h"
11 #include "base/files/file_path.h"
12 #include "base/memory/ref_counted.h"
13 #include "net/disk_cache/blockfile/addr.h"
14 #include "net/disk_cache/blockfile/backend_impl_v3.h"
15 #include "net/disk_cache/blockfile/block_files.h"
17 namespace base {
18 class SingleThreadTaskRunner;
19 } // namespace base
21 namespace disk_cache {
23 class BackendImplV3::Worker : public base::RefCountedThreadSafe<Worker> {
24 public:
25 Worker(const base::FilePath& path,
26 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread);
28 // Performs general initialization for this current instance of the cache.
29 int Init(const CompletionCallback& callback);
31 private:
32 friend class base::RefCountedThreadSafe<Worker>;
34 ~Worker();
35 void CleanupCache();
37 // Returns the full name for an external storage file.
38 base::FilePath GetFileName(Addr address) const;
40 // Creates a new backing file for the cache index.
41 bool CreateBackingStore(disk_cache::File* file);
42 bool InitBackingStore(bool* file_created);
44 // Performs basic checks on the index file. Returns false on failure.
45 bool CheckIndex();
47 base::FilePath path_; // Path to the folder used as backing storage.
48 BlockFiles block_files_; // Set of files used to store all data.
49 bool init_; // controls the initialization of the system.
51 DISALLOW_COPY_AND_ASSIGN(Worker);
54 } // namespace disk_cache
56 #endif // NET_DISK_CACHE_BLOCKFILE_BACKEND_WORKER_V3_H_