1// Copyright 2014 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#ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_PROVIDER_ASYNC_FILE_UTIL_H_
6#define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_PROVIDER_ASYNC_FILE_UTIL_H_
7
8#include "base/basictypes.h"
9#include "base/callback.h"
10#include "storage/browser/fileapi/async_file_util.h"
11
12namespace chromeos {
13namespace file_system_provider {
14
15class FileSystemInterface;
16
17namespace internal {
18
19// The implementation of storage::AsyncFileUtil for provided file systems. It is
20// created one per Chrome process. It is responsible for routing calls to the
21// correct profile, and then to the correct profided file system.
22//
23// This class should be called AsyncFileUtil, without the Provided prefix. This
24// is impossible, though because of GYP limitations. There must not be two files
25// with the same name in a Chromium tree.
26// See: https://code.google.com/p/gyp/issues/detail?id=384
27//
28// All of the methods should be called on the IO thread.
29class ProviderAsyncFileUtil : public storage::AsyncFileUtil {
30 public:
31  ProviderAsyncFileUtil();
32  virtual ~ProviderAsyncFileUtil();
33
34  // storage::AsyncFileUtil overrides.
35  virtual void CreateOrOpen(
36      scoped_ptr<storage::FileSystemOperationContext> context,
37      const storage::FileSystemURL& url,
38      int file_flags,
39      const CreateOrOpenCallback& callback) OVERRIDE;
40  virtual void EnsureFileExists(
41      scoped_ptr<storage::FileSystemOperationContext> context,
42      const storage::FileSystemURL& url,
43      const EnsureFileExistsCallback& callback) OVERRIDE;
44  virtual void CreateDirectory(
45      scoped_ptr<storage::FileSystemOperationContext> context,
46      const storage::FileSystemURL& url,
47      bool exclusive,
48      bool recursive,
49      const StatusCallback& callback) OVERRIDE;
50  virtual void GetFileInfo(
51      scoped_ptr<storage::FileSystemOperationContext> context,
52      const storage::FileSystemURL& url,
53      const GetFileInfoCallback& callback) OVERRIDE;
54  virtual void ReadDirectory(
55      scoped_ptr<storage::FileSystemOperationContext> context,
56      const storage::FileSystemURL& url,
57      const ReadDirectoryCallback& callback) OVERRIDE;
58  virtual void Touch(scoped_ptr<storage::FileSystemOperationContext> context,
59                     const storage::FileSystemURL& url,
60                     const base::Time& last_access_time,
61                     const base::Time& last_modified_time,
62                     const StatusCallback& callback) OVERRIDE;
63  virtual void Truncate(scoped_ptr<storage::FileSystemOperationContext> context,
64                        const storage::FileSystemURL& url,
65                        int64 length,
66                        const StatusCallback& callback) OVERRIDE;
67  virtual void CopyFileLocal(
68      scoped_ptr<storage::FileSystemOperationContext> context,
69      const storage::FileSystemURL& src_url,
70      const storage::FileSystemURL& dest_url,
71      CopyOrMoveOption option,
72      const CopyFileProgressCallback& progress_callback,
73      const StatusCallback& callback) OVERRIDE;
74  virtual void MoveFileLocal(
75      scoped_ptr<storage::FileSystemOperationContext> context,
76      const storage::FileSystemURL& src_url,
77      const storage::FileSystemURL& dest_url,
78      CopyOrMoveOption option,
79      const StatusCallback& callback) OVERRIDE;
80  virtual void CopyInForeignFile(
81      scoped_ptr<storage::FileSystemOperationContext> context,
82      const base::FilePath& src_file_path,
83      const storage::FileSystemURL& dest_url,
84      const StatusCallback& callback) OVERRIDE;
85  virtual void DeleteFile(
86      scoped_ptr<storage::FileSystemOperationContext> context,
87      const storage::FileSystemURL& url,
88      const StatusCallback& callback) OVERRIDE;
89  virtual void DeleteDirectory(
90      scoped_ptr<storage::FileSystemOperationContext> context,
91      const storage::FileSystemURL& url,
92      const StatusCallback& callback) OVERRIDE;
93  virtual void DeleteRecursively(
94      scoped_ptr<storage::FileSystemOperationContext> context,
95      const storage::FileSystemURL& url,
96      const StatusCallback& callback) OVERRIDE;
97  virtual void CreateSnapshotFile(
98      scoped_ptr<storage::FileSystemOperationContext> context,
99      const storage::FileSystemURL& url,
100      const CreateSnapshotFileCallback& callback) OVERRIDE;
101
102 private:
103  DISALLOW_COPY_AND_ASSIGN(ProviderAsyncFileUtil);
104};
105
106}  // namespace internal
107}  // namespace file_system_provider
108}  // namespace chromeos
109
110#endif  // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_PROVIDER_ASYNC_FILE_UTIL_H_
111