Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / net / disk_cache / blockfile / backend_worker_v3.h
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 "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"
16
17 namespace base {
18 class SingleThreadTaskRunner;
19 }  // namespace base
20
21 namespace disk_cache {
22
23 class BackendImplV3::Worker : public base::RefCountedThreadSafe<Worker> {
24  public:
25   Worker(const base::FilePath& path,
26          const scoped_refptr<base::SingleThreadTaskRunner>& main_thread);
27
28   // Performs general initialization for this current instance of the cache.
29   int Init(const CompletionCallback& callback);
30
31  private:
32   friend class base::RefCountedThreadSafe<Worker>;
33
34   ~Worker();
35   void CleanupCache();
36
37   // Returns the full name for an external storage file.
38   base::FilePath GetFileName(Addr address) const;
39
40   // Creates a new backing file for the cache index.
41   bool CreateBackingStore(disk_cache::File* file);
42   bool InitBackingStore(bool* file_created);
43
44   // Performs basic checks on the index file. Returns false on failure.
45   bool CheckIndex();
46
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.
50
51   DISALLOW_COPY_AND_ASSIGN(Worker);
52 };
53
54 }  // namespace disk_cache
55
56 #endif  // NET_DISK_CACHE_BLOCKFILE_BACKEND_WORKER_V3_H_