Home | History | Annotate | Download | only in fileapi
      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.
      4 
      5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_SYSTEM_BACKEND_H_
      6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_SYSTEM_BACKEND_H_
      7 
      8 #include "base/memory/ref_counted.h"
      9 #include "base/memory/scoped_ptr.h"
     10 #include "webkit/browser/fileapi/file_system_backend.h"
     11 
     12 namespace base {
     13 class SequencedTaskRunner;
     14 }
     15 
     16 namespace fileapi {
     17 class AsyncFileUtilAdapter;
     18 }
     19 
     20 namespace chrome {
     21 
     22 class MediaPathFilter;
     23 
     24 class DeviceMediaAsyncFileUtil;
     25 
     26 class MediaFileSystemBackend : public fileapi::FileSystemBackend {
     27  public:
     28   static const char kMediaTaskRunnerName[];
     29 
     30   MediaFileSystemBackend(
     31       const base::FilePath& profile_path,
     32       base::SequencedTaskRunner* media_task_runner);
     33   virtual ~MediaFileSystemBackend();
     34 
     35   static bool CurrentlyOnMediaTaskRunnerThread();
     36   static scoped_refptr<base::SequencedTaskRunner> MediaTaskRunner();
     37 
     38   // FileSystemBackend implementation.
     39   virtual bool CanHandleType(fileapi::FileSystemType type) const OVERRIDE;
     40   virtual void Initialize(fileapi::FileSystemContext* context) OVERRIDE;
     41   virtual void OpenFileSystem(
     42       const GURL& origin_url,
     43       fileapi::FileSystemType type,
     44       fileapi::OpenFileSystemMode mode,
     45       const OpenFileSystemCallback& callback) OVERRIDE;
     46   virtual fileapi::FileSystemFileUtil* GetFileUtil(
     47       fileapi::FileSystemType type) OVERRIDE;
     48   virtual fileapi::AsyncFileUtil* GetAsyncFileUtil(
     49       fileapi::FileSystemType type) OVERRIDE;
     50   virtual fileapi::CopyOrMoveFileValidatorFactory*
     51   GetCopyOrMoveFileValidatorFactory(
     52       fileapi::FileSystemType type,
     53       base::PlatformFileError* error_code) OVERRIDE;
     54   virtual fileapi::FileSystemOperation* CreateFileSystemOperation(
     55       const fileapi::FileSystemURL& url,
     56       fileapi::FileSystemContext* context,
     57       base::PlatformFileError* error_code) const OVERRIDE;
     58   virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader(
     59       const fileapi::FileSystemURL& url,
     60       int64 offset,
     61       const base::Time& expected_modification_time,
     62       fileapi::FileSystemContext* context) const OVERRIDE;
     63   virtual scoped_ptr<fileapi::FileStreamWriter> CreateFileStreamWriter(
     64       const fileapi::FileSystemURL& url,
     65       int64 offset,
     66       fileapi::FileSystemContext* context) const OVERRIDE;
     67   virtual fileapi::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE;
     68 
     69  private:
     70   // Store the profile path. We need this to create temporary snapshot files.
     71   const base::FilePath profile_path_;
     72 
     73   scoped_refptr<base::SequencedTaskRunner> media_task_runner_;
     74 
     75   scoped_ptr<MediaPathFilter> media_path_filter_;
     76   scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory>
     77       media_copy_or_move_file_validator_factory_;
     78 
     79   scoped_ptr<fileapi::AsyncFileUtil> native_media_file_util_;
     80   scoped_ptr<DeviceMediaAsyncFileUtil> device_media_async_file_util_;
     81 #if defined(OS_WIN) || defined(OS_MACOSX)
     82   scoped_ptr<fileapi::AsyncFileUtil> picasa_file_util_;
     83   scoped_ptr<fileapi::AsyncFileUtil> itunes_file_util_;
     84 #endif  // defined(OS_WIN) || defined(OS_MACOSX)
     85 
     86   DISALLOW_COPY_AND_ASSIGN(MediaFileSystemBackend);
     87 };
     88 
     89 }  // namespace chrome
     90 
     91 #endif  // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_SYSTEM_BACKEND_H_
     92