Home | History | Annotate | Download | only in drive
      1 // Copyright 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.
      4 
      5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_ASYNC_FILE_UTIL_H_
      6 #define CHROME_BROWSER_CHROMEOS_DRIVE_ASYNC_FILE_UTIL_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "base/callback.h"
     10 #include "webkit/browser/fileapi/async_file_util.h"
     11 
     12 namespace drive {
     13 
     14 class FileSystemInterface;
     15 
     16 namespace internal {
     17 
     18 // The implementation of fileapi::AsyncFileUtil for Drive File System.
     19 class AsyncFileUtil : public fileapi::AsyncFileUtil {
     20  public:
     21   // Callback to return the FileSystemInterface instance. This is an
     22   // injecting point for testing.
     23   // Note that the callback will be copied between threads (IO and UI), and
     24   // will be called on UI thread.
     25   typedef base::Callback<FileSystemInterface*()> FileSystemGetter;
     26 
     27   explicit AsyncFileUtil(const FileSystemGetter& file_system_getter);
     28   virtual ~AsyncFileUtil();
     29 
     30   // fileapi::AsyncFileUtil overrides.
     31   virtual void CreateOrOpen(
     32       scoped_ptr<fileapi::FileSystemOperationContext> context,
     33       const fileapi::FileSystemURL& url,
     34       int file_flags,
     35       const CreateOrOpenCallback& callback) OVERRIDE;
     36   virtual void EnsureFileExists(
     37       scoped_ptr<fileapi::FileSystemOperationContext> context,
     38       const fileapi::FileSystemURL& url,
     39       const EnsureFileExistsCallback& callback) OVERRIDE;
     40   virtual void CreateDirectory(
     41       scoped_ptr<fileapi::FileSystemOperationContext> context,
     42       const fileapi::FileSystemURL& url,
     43       bool exclusive,
     44       bool recursive,
     45       const StatusCallback& callback) OVERRIDE;
     46   virtual void GetFileInfo(
     47       scoped_ptr<fileapi::FileSystemOperationContext> context,
     48       const fileapi::FileSystemURL& url,
     49       const GetFileInfoCallback& callback) OVERRIDE;
     50   virtual void ReadDirectory(
     51       scoped_ptr<fileapi::FileSystemOperationContext> context,
     52       const fileapi::FileSystemURL& url,
     53       const ReadDirectoryCallback& callback) OVERRIDE;
     54   virtual void Touch(
     55       scoped_ptr<fileapi::FileSystemOperationContext> context,
     56       const fileapi::FileSystemURL& url,
     57       const base::Time& last_access_time,
     58       const base::Time& last_modified_time,
     59       const StatusCallback& callback) OVERRIDE;
     60   virtual void Truncate(
     61       scoped_ptr<fileapi::FileSystemOperationContext> context,
     62       const fileapi::FileSystemURL& url,
     63       int64 length,
     64       const StatusCallback& callback) OVERRIDE;
     65   virtual void CopyFileLocal(
     66       scoped_ptr<fileapi::FileSystemOperationContext> context,
     67       const fileapi::FileSystemURL& src_url,
     68       const fileapi::FileSystemURL& dest_url,
     69       const StatusCallback& callback) OVERRIDE;
     70   virtual void MoveFileLocal(
     71       scoped_ptr<fileapi::FileSystemOperationContext> context,
     72       const fileapi::FileSystemURL& src_url,
     73       const fileapi::FileSystemURL& dest_url,
     74       const StatusCallback& callback) OVERRIDE;
     75   virtual void CopyInForeignFile(
     76       scoped_ptr<fileapi::FileSystemOperationContext> context,
     77       const base::FilePath& src_file_path,
     78       const fileapi::FileSystemURL& dest_url,
     79       const StatusCallback& callback) OVERRIDE;
     80   virtual void DeleteFile(
     81       scoped_ptr<fileapi::FileSystemOperationContext> context,
     82       const fileapi::FileSystemURL& url,
     83       const StatusCallback& callback) OVERRIDE;
     84   virtual void DeleteDirectory(
     85       scoped_ptr<fileapi::FileSystemOperationContext> context,
     86       const fileapi::FileSystemURL& url,
     87       const StatusCallback& callback) OVERRIDE;
     88   virtual void DeleteRecursively(
     89       scoped_ptr<fileapi::FileSystemOperationContext> context,
     90       const fileapi::FileSystemURL& url,
     91       const StatusCallback& callback) OVERRIDE;
     92   virtual void CreateSnapshotFile(
     93       scoped_ptr<fileapi::FileSystemOperationContext> context,
     94       const fileapi::FileSystemURL& url,
     95       const CreateSnapshotFileCallback& callback) OVERRIDE;
     96 
     97  private:
     98   FileSystemGetter file_system_getter_;
     99 
    100   DISALLOW_COPY_AND_ASSIGN(AsyncFileUtil);
    101 };
    102 
    103 }  // namespace internal
    104 }  // namespace drive
    105 
    106 #endif  // CHROME_BROWSER_CHROMEOS_DRIVE_ASYNC_FILE_UTIL_H_
    107