blob: b1b07a732a285bc3b3c8586df0dae86e0487dbe7 [file] [log] [blame]
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +01001// 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_MOUNT_POINT_PROVIDER_H_
6#define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_SYSTEM_MOUNT_POINT_PROVIDER_H_
7
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +01008#include "base/memory/ref_counted.h"
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +01009#include "base/memory/scoped_ptr.h"
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010010#include "webkit/browser/fileapi/file_system_mount_point_provider.h"
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010011
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010012namespace base {
13class SequencedTaskRunner;
14}
15
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010016namespace fileapi {
17class AsyncFileUtilAdapter;
18}
19
20namespace chrome {
21
22class MediaPathFilter;
23
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010024class DeviceMediaAsyncFileUtil;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010025
26class MediaFileSystemMountPointProvider
27 : public fileapi::FileSystemMountPointProvider {
28 public:
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010029 static const char kMediaTaskRunnerName[];
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010030 static const char kMediaPathFilterKey[];
31 static const char kMTPDeviceDelegateURLKey[];
32
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010033 MediaFileSystemMountPointProvider(
34 const base::FilePath& profile_path,
35 base::SequencedTaskRunner* media_task_runner);
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010036 virtual ~MediaFileSystemMountPointProvider();
37
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +010038 static bool CurrentlyOnMediaTaskRunnerThread();
39
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010040 // FileSystemMountPointProvider implementation.
41 virtual bool CanHandleType(fileapi::FileSystemType type) const OVERRIDE;
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010042 virtual void OpenFileSystem(
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010043 const GURL& origin_url,
44 fileapi::FileSystemType type,
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010045 fileapi::OpenFileSystemMode mode,
46 const OpenFileSystemCallback& callback) OVERRIDE;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010047 virtual fileapi::FileSystemFileUtil* GetFileUtil(
48 fileapi::FileSystemType type) OVERRIDE;
49 virtual fileapi::AsyncFileUtil* GetAsyncFileUtil(
50 fileapi::FileSystemType type) OVERRIDE;
51 virtual fileapi::CopyOrMoveFileValidatorFactory*
52 GetCopyOrMoveFileValidatorFactory(
53 fileapi::FileSystemType type,
54 base::PlatformFileError* error_code) OVERRIDE;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010055 virtual fileapi::FilePermissionPolicy GetPermissionPolicy(
56 const fileapi::FileSystemURL& url, int permissions) const OVERRIDE;
57 virtual fileapi::FileSystemOperation* CreateFileSystemOperation(
58 const fileapi::FileSystemURL& url,
59 fileapi::FileSystemContext* context,
60 base::PlatformFileError* error_code) const OVERRIDE;
61 virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader(
62 const fileapi::FileSystemURL& url,
63 int64 offset,
64 const base::Time& expected_modification_time,
65 fileapi::FileSystemContext* context) const OVERRIDE;
66 virtual scoped_ptr<fileapi::FileStreamWriter> CreateFileStreamWriter(
67 const fileapi::FileSystemURL& url,
68 int64 offset,
69 fileapi::FileSystemContext* context) const OVERRIDE;
70 virtual fileapi::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE;
71 virtual void DeleteFileSystem(
72 const GURL& origin_url,
73 fileapi::FileSystemType type,
74 fileapi::FileSystemContext* context,
75 const DeleteFileSystemCallback& callback) OVERRIDE;
76
77 private:
78 // Store the profile path. We need this to create temporary snapshot files.
79 const base::FilePath profile_path_;
80
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010081 scoped_refptr<base::SequencedTaskRunner> media_task_runner_;
82
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010083 scoped_ptr<MediaPathFilter> media_path_filter_;
84 scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory>
85 media_copy_or_move_file_validator_factory_;
86
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010087 scoped_ptr<fileapi::AsyncFileUtil> native_media_file_util_;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010088 scoped_ptr<DeviceMediaAsyncFileUtil> device_media_async_file_util_;
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010089 scoped_ptr<fileapi::AsyncFileUtil> picasa_file_util_;
Torne (Richard Coles)b2df76e2013-05-13 16:52:09 +010090 scoped_ptr<fileapi::AsyncFileUtil> itunes_file_util_;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010091
92 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemMountPointProvider);
93};
94
95} // namespace chrome
96
97#endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_SYSTEM_MOUNT_POINT_PROVIDER_H_