Adding instrumentation to locate the source of jankiness
[chromium-blink-merge.git] / chrome / browser / media_galleries / fileapi / media_file_system_backend.h
blobaa164d041579cb0dae0c8312bc546e79fca924fb
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 CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_SYSTEM_BACKEND_H_
6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_SYSTEM_BACKEND_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/files/file_path.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/media_galleries/media_galleries_preferences.h"
15 #include "storage/browser/fileapi/file_system_backend.h"
16 #include "storage/browser/fileapi/task_runner_bound_observer_list.h"
18 namespace base {
19 class SequencedTaskRunner;
22 namespace storage {
23 class FileSystemURL;
26 namespace net {
27 class URLRequest;
30 class MediaPathFilter;
31 class DeviceMediaAsyncFileUtil;
33 class MediaFileSystemBackend : public storage::FileSystemBackend {
34 public:
35 static const char kMediaTaskRunnerName[];
37 MediaFileSystemBackend(
38 const base::FilePath& profile_path,
39 base::SequencedTaskRunner* media_task_runner);
40 virtual ~MediaFileSystemBackend();
42 static bool CurrentlyOnMediaTaskRunnerThread();
43 static scoped_refptr<base::SequencedTaskRunner> MediaTaskRunner();
45 // Construct the mount point for the gallery specified by |pref_id| in
46 // the profile located in |profile_path|.
47 static std::string ConstructMountName(const base::FilePath& profile_path,
48 const std::string& extension_id,
49 MediaGalleryPrefId pref_id);
51 static bool AttemptAutoMountForURLRequest(
52 const net::URLRequest* url_request,
53 const storage::FileSystemURL& filesystem_url,
54 const std::string& storage_domain,
55 const base::Callback<void(base::File::Error result)>& callback);
57 // FileSystemBackend implementation.
58 virtual bool CanHandleType(storage::FileSystemType type) const override;
59 virtual void Initialize(storage::FileSystemContext* context) override;
60 virtual void ResolveURL(const storage::FileSystemURL& url,
61 storage::OpenFileSystemMode mode,
62 const OpenFileSystemCallback& callback) override;
63 virtual storage::AsyncFileUtil* GetAsyncFileUtil(
64 storage::FileSystemType type) override;
65 virtual storage::WatcherManager* GetWatcherManager(
66 storage::FileSystemType type) override;
67 virtual storage::CopyOrMoveFileValidatorFactory*
68 GetCopyOrMoveFileValidatorFactory(storage::FileSystemType type,
69 base::File::Error* error_code) override;
70 virtual storage::FileSystemOperation* CreateFileSystemOperation(
71 const storage::FileSystemURL& url,
72 storage::FileSystemContext* context,
73 base::File::Error* error_code) const override;
74 virtual bool SupportsStreaming(
75 const storage::FileSystemURL& url) const override;
76 virtual bool HasInplaceCopyImplementation(
77 storage::FileSystemType type) const override;
78 virtual scoped_ptr<storage::FileStreamReader> CreateFileStreamReader(
79 const storage::FileSystemURL& url,
80 int64 offset,
81 int64 max_bytes_to_read,
82 const base::Time& expected_modification_time,
83 storage::FileSystemContext* context) const override;
84 virtual scoped_ptr<storage::FileStreamWriter> CreateFileStreamWriter(
85 const storage::FileSystemURL& url,
86 int64 offset,
87 storage::FileSystemContext* context) const override;
88 virtual storage::FileSystemQuotaUtil* GetQuotaUtil() override;
89 virtual const storage::UpdateObserverList* GetUpdateObservers(
90 storage::FileSystemType type) const override;
91 virtual const storage::ChangeObserverList* GetChangeObservers(
92 storage::FileSystemType type) const override;
93 virtual const storage::AccessObserverList* GetAccessObservers(
94 storage::FileSystemType type) const override;
96 private:
97 // Store the profile path. We need this to create temporary snapshot files.
98 const base::FilePath profile_path_;
100 scoped_refptr<base::SequencedTaskRunner> media_task_runner_;
102 scoped_ptr<MediaPathFilter> media_path_filter_;
103 scoped_ptr<storage::CopyOrMoveFileValidatorFactory>
104 media_copy_or_move_file_validator_factory_;
106 scoped_ptr<storage::AsyncFileUtil> native_media_file_util_;
107 scoped_ptr<DeviceMediaAsyncFileUtil> device_media_async_file_util_;
108 #if defined(OS_WIN) || defined(OS_MACOSX)
109 scoped_ptr<storage::AsyncFileUtil> picasa_file_util_;
110 scoped_ptr<storage::AsyncFileUtil> itunes_file_util_;
111 #endif // defined(OS_WIN) || defined(OS_MACOSX)
112 #if defined(OS_MACOSX)
113 scoped_ptr<storage::AsyncFileUtil> iphoto_file_util_;
114 #endif // defined(OS_MACOSX)
116 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemBackend);
119 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_SYSTEM_BACKEND_H_