Include all dupe types (event when value is zero) in scan stats.
[chromium-blink-merge.git] / storage / browser / fileapi / async_file_util_adapter.h
blob9c661a6d4e829ed7bde9bcb62766f8dd4948e2c0
1 // Copyright (c) 2013 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 #ifndef STORAGE_BROWSER_FILEAPI_ASYNC_FILE_UTIL_ADAPTER_H_
6 #define STORAGE_BROWSER_FILEAPI_ASYNC_FILE_UTIL_ADAPTER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "storage/browser/fileapi/async_file_util.h"
11 namespace storage {
13 class FileSystemFileUtil;
15 // An adapter class for FileSystemFileUtil classes to provide asynchronous
16 // interface.
18 // A filesystem can do either:
19 // - implement a synchronous version of FileUtil by extending
20 // FileSystemFileUtil and atach it to this adapter, or
21 // - directly implement AsyncFileUtil.
23 // This instance (as thus this->sync_file_util_) is guaranteed to be alive
24 // as far as FileSystemOperationContext given to each operation is kept alive.
25 class STORAGE_EXPORT AsyncFileUtilAdapter
26 : public NON_EXPORTED_BASE(AsyncFileUtil) {
27 public:
28 // Creates a new AsyncFileUtil for |sync_file_util|. This takes the
29 // ownership of |sync_file_util|. (This doesn't take scoped_ptr<> just
30 // to save extra make_scoped_ptr; in all use cases a new fresh FileUtil is
31 // created only for this adapter.)
32 explicit AsyncFileUtilAdapter(FileSystemFileUtil* sync_file_util);
34 ~AsyncFileUtilAdapter() override;
36 FileSystemFileUtil* sync_file_util() {
37 return sync_file_util_.get();
40 // AsyncFileUtil overrides.
41 void CreateOrOpen(scoped_ptr<FileSystemOperationContext> context,
42 const FileSystemURL& url,
43 int file_flags,
44 const CreateOrOpenCallback& callback) override;
45 void EnsureFileExists(scoped_ptr<FileSystemOperationContext> context,
46 const FileSystemURL& url,
47 const EnsureFileExistsCallback& callback) override;
48 void CreateDirectory(scoped_ptr<FileSystemOperationContext> context,
49 const FileSystemURL& url,
50 bool exclusive,
51 bool recursive,
52 const StatusCallback& callback) override;
53 void GetFileInfo(scoped_ptr<FileSystemOperationContext> context,
54 const FileSystemURL& url,
55 const GetFileInfoCallback& callback) override;
56 void ReadDirectory(scoped_ptr<FileSystemOperationContext> context,
57 const FileSystemURL& url,
58 const ReadDirectoryCallback& callback) override;
59 void Touch(scoped_ptr<FileSystemOperationContext> context,
60 const FileSystemURL& url,
61 const base::Time& last_access_time,
62 const base::Time& last_modified_time,
63 const StatusCallback& callback) override;
64 void Truncate(scoped_ptr<FileSystemOperationContext> context,
65 const FileSystemURL& url,
66 int64 length,
67 const StatusCallback& callback) override;
68 void CopyFileLocal(scoped_ptr<FileSystemOperationContext> context,
69 const FileSystemURL& src_url,
70 const FileSystemURL& dest_url,
71 CopyOrMoveOption option,
72 const CopyFileProgressCallback& progress_callback,
73 const StatusCallback& callback) override;
74 void MoveFileLocal(scoped_ptr<FileSystemOperationContext> context,
75 const FileSystemURL& src_url,
76 const FileSystemURL& dest_url,
77 CopyOrMoveOption option,
78 const StatusCallback& callback) override;
79 void CopyInForeignFile(scoped_ptr<FileSystemOperationContext> context,
80 const base::FilePath& src_file_path,
81 const FileSystemURL& dest_url,
82 const StatusCallback& callback) override;
83 void DeleteFile(scoped_ptr<FileSystemOperationContext> context,
84 const FileSystemURL& url,
85 const StatusCallback& callback) override;
86 void DeleteDirectory(scoped_ptr<FileSystemOperationContext> context,
87 const FileSystemURL& url,
88 const StatusCallback& callback) override;
89 void DeleteRecursively(scoped_ptr<FileSystemOperationContext> context,
90 const FileSystemURL& url,
91 const StatusCallback& callback) override;
92 void CreateSnapshotFile(scoped_ptr<FileSystemOperationContext> context,
93 const FileSystemURL& url,
94 const CreateSnapshotFileCallback& callback) override;
96 private:
97 scoped_ptr<FileSystemFileUtil> sync_file_util_;
99 DISALLOW_COPY_AND_ASSIGN(AsyncFileUtilAdapter);
102 } // namespace storage
104 #endif // STORAGE_BROWSER_FILEAPI_ASYNC_FILE_UTIL_ADAPTER_H_