| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_H_ | 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> |
| 11 #include <string> | 12 #include <string> |
| 12 | 13 |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "chrome/browser/chromeos/file_system_provider/abort_callback.h" | 18 #include "chrome/browser/chromeos/file_system_provider/abort_callback.h" |
| 19 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" | 19 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" |
| 20 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" | 20 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" |
| 21 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_obse
rver.h" | 21 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_obse
rver.h" |
| 22 #include "chrome/browser/chromeos/file_system_provider/queue.h" | 22 #include "chrome/browser/chromeos/file_system_provider/queue.h" |
| 23 #include "chrome/browser/chromeos/file_system_provider/request_manager.h" | 23 #include "chrome/browser/chromeos/file_system_provider/request_manager.h" |
| 24 #include "storage/browser/fileapi/async_file_util.h" | 24 #include "storage/browser/fileapi/async_file_util.h" |
| 25 #include "storage/browser/fileapi/watcher_manager.h" | 25 #include "storage/browser/fileapi/watcher_manager.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 ~ProvidedFileSystem() override; | 84 ~ProvidedFileSystem() override; |
| 85 | 85 |
| 86 // Sets a custom event router. Used in unit tests to mock out the real | 86 // Sets a custom event router. Used in unit tests to mock out the real |
| 87 // extension. | 87 // extension. |
| 88 void SetEventRouterForTesting(extensions::EventRouter* event_router); | 88 void SetEventRouterForTesting(extensions::EventRouter* event_router); |
| 89 | 89 |
| 90 // Sets a custom notification manager. It will recreate the request manager, | 90 // Sets a custom notification manager. It will recreate the request manager, |
| 91 // so is must be called just after creating ProvideFileSystem instance. | 91 // so is must be called just after creating ProvideFileSystem instance. |
| 92 // Used by unit tests. | 92 // Used by unit tests. |
| 93 void SetNotificationManagerForTesting( | 93 void SetNotificationManagerForTesting( |
| 94 scoped_ptr<NotificationManagerInterface> notification_manager); | 94 std::unique_ptr<NotificationManagerInterface> notification_manager); |
| 95 | 95 |
| 96 // ProvidedFileSystemInterface overrides. | 96 // ProvidedFileSystemInterface overrides. |
| 97 AbortCallback RequestUnmount( | 97 AbortCallback RequestUnmount( |
| 98 const storage::AsyncFileUtil::StatusCallback& callback) override; | 98 const storage::AsyncFileUtil::StatusCallback& callback) override; |
| 99 AbortCallback GetMetadata(const base::FilePath& entry_path, | 99 AbortCallback GetMetadata(const base::FilePath& entry_path, |
| 100 MetadataFieldMask fields, | 100 MetadataFieldMask fields, |
| 101 const GetMetadataCallback& callback) override; | 101 const GetMetadataCallback& callback) override; |
| 102 AbortCallback GetActions(const std::vector<base::FilePath>& entry_paths, | 102 AbortCallback GetActions(const std::vector<base::FilePath>& entry_paths, |
| 103 const GetActionsCallback& callback) override; | 103 const GetActionsCallback& callback) override; |
| 104 AbortCallback ExecuteAction( | 104 AbortCallback ExecuteAction( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 const storage::AsyncFileUtil::StatusCallback& callback) override; | 163 const storage::AsyncFileUtil::StatusCallback& callback) override; |
| 164 const ProvidedFileSystemInfo& GetFileSystemInfo() const override; | 164 const ProvidedFileSystemInfo& GetFileSystemInfo() const override; |
| 165 RequestManager* GetRequestManager() override; | 165 RequestManager* GetRequestManager() override; |
| 166 Watchers* GetWatchers() override; | 166 Watchers* GetWatchers() override; |
| 167 const OpenedFiles& GetOpenedFiles() const override; | 167 const OpenedFiles& GetOpenedFiles() const override; |
| 168 void AddObserver(ProvidedFileSystemObserver* observer) override; | 168 void AddObserver(ProvidedFileSystemObserver* observer) override; |
| 169 void RemoveObserver(ProvidedFileSystemObserver* observer) override; | 169 void RemoveObserver(ProvidedFileSystemObserver* observer) override; |
| 170 void Notify(const base::FilePath& entry_path, | 170 void Notify(const base::FilePath& entry_path, |
| 171 bool recursive, | 171 bool recursive, |
| 172 storage::WatcherManager::ChangeType change_type, | 172 storage::WatcherManager::ChangeType change_type, |
| 173 scoped_ptr<ProvidedFileSystemObserver::Changes> changes, | 173 std::unique_ptr<ProvidedFileSystemObserver::Changes> changes, |
| 174 const std::string& tag, | 174 const std::string& tag, |
| 175 const storage::AsyncFileUtil::StatusCallback& callback) override; | 175 const storage::AsyncFileUtil::StatusCallback& callback) override; |
| 176 void Configure( | 176 void Configure( |
| 177 const storage::AsyncFileUtil::StatusCallback& callback) override; | 177 const storage::AsyncFileUtil::StatusCallback& callback) override; |
| 178 base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() override; | 178 base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() override; |
| 179 | 179 |
| 180 private: | 180 private: |
| 181 // Wrapper for arguments for AddWatcherInQueue, as it's too many of them to | 181 // Wrapper for arguments for AddWatcherInQueue, as it's too many of them to |
| 182 // be used by base::Bind. | 182 // be used by base::Bind. |
| 183 struct AddWatcherInQueueArgs; | 183 struct AddWatcherInQueueArgs; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 199 | 199 |
| 200 // Removes a watcher within |watcher_queue_|. | 200 // Removes a watcher within |watcher_queue_|. |
| 201 AbortCallback RemoveWatcherInQueue( | 201 AbortCallback RemoveWatcherInQueue( |
| 202 size_t token, | 202 size_t token, |
| 203 const GURL& origin, | 203 const GURL& origin, |
| 204 const base::FilePath& entry_path, | 204 const base::FilePath& entry_path, |
| 205 bool recursive, | 205 bool recursive, |
| 206 const storage::AsyncFileUtil::StatusCallback& callback); | 206 const storage::AsyncFileUtil::StatusCallback& callback); |
| 207 | 207 |
| 208 // Notifies about a notifier even within |watcher_queue_|. | 208 // Notifies about a notifier even within |watcher_queue_|. |
| 209 AbortCallback NotifyInQueue(scoped_ptr<NotifyInQueueArgs> args); | 209 AbortCallback NotifyInQueue(std::unique_ptr<NotifyInQueueArgs> args); |
| 210 | 210 |
| 211 // Called when adding a watcher is completed with either success or en error. | 211 // Called when adding a watcher is completed with either success or en error. |
| 212 void OnAddWatcherInQueueCompleted( | 212 void OnAddWatcherInQueueCompleted( |
| 213 size_t token, | 213 size_t token, |
| 214 const base::FilePath& entry_path, | 214 const base::FilePath& entry_path, |
| 215 bool recursive, | 215 bool recursive, |
| 216 const Subscriber& subscriber, | 216 const Subscriber& subscriber, |
| 217 const storage::AsyncFileUtil::StatusCallback& callback, | 217 const storage::AsyncFileUtil::StatusCallback& callback, |
| 218 base::File::Error result); | 218 base::File::Error result); |
| 219 | 219 |
| 220 // Called when adding a watcher is completed with either a success or an | 220 // Called when adding a watcher is completed with either a success or an |
| 221 // error. | 221 // error. |
| 222 void OnRemoveWatcherInQueueCompleted( | 222 void OnRemoveWatcherInQueueCompleted( |
| 223 size_t token, | 223 size_t token, |
| 224 const GURL& origin, | 224 const GURL& origin, |
| 225 const WatcherKey& key, | 225 const WatcherKey& key, |
| 226 const storage::AsyncFileUtil::StatusCallback& callback, | 226 const storage::AsyncFileUtil::StatusCallback& callback, |
| 227 bool extension_response, | 227 bool extension_response, |
| 228 base::File::Error result); | 228 base::File::Error result); |
| 229 | 229 |
| 230 // Called when all observers finished handling the change notification. It | 230 // Called when all observers finished handling the change notification. It |
| 231 // updates the tag to |tag| for the entry at |entry_path|. | 231 // updates the tag to |tag| for the entry at |entry_path|. |
| 232 void OnNotifyInQueueCompleted(scoped_ptr<NotifyInQueueArgs> args, | 232 void OnNotifyInQueueCompleted(std::unique_ptr<NotifyInQueueArgs> args, |
| 233 const base::File::Error result); | 233 const base::File::Error result); |
| 234 | 234 |
| 235 // Called when opening a file is completed with either a success or an error. | 235 // Called when opening a file is completed with either a success or an error. |
| 236 void OnOpenFileCompleted(const base::FilePath& file_path, | 236 void OnOpenFileCompleted(const base::FilePath& file_path, |
| 237 OpenFileMode mode, | 237 OpenFileMode mode, |
| 238 const OpenFileCallback& callback, | 238 const OpenFileCallback& callback, |
| 239 int file_handle, | 239 int file_handle, |
| 240 base::File::Error result); | 240 base::File::Error result); |
| 241 | 241 |
| 242 // Called when closing a file is completed with either a success or an error. | 242 // Called when closing a file is completed with either a success or an error. |
| 243 void OnCloseFileCompleted( | 243 void OnCloseFileCompleted( |
| 244 int file_handle, | 244 int file_handle, |
| 245 const storage::AsyncFileUtil::StatusCallback& callback, | 245 const storage::AsyncFileUtil::StatusCallback& callback, |
| 246 base::File::Error result); | 246 base::File::Error result); |
| 247 | 247 |
| 248 Profile* profile_; // Not owned. | 248 Profile* profile_; // Not owned. |
| 249 extensions::EventRouter* event_router_; // Not owned. May be NULL. | 249 extensions::EventRouter* event_router_; // Not owned. May be NULL. |
| 250 ProvidedFileSystemInfo file_system_info_; | 250 ProvidedFileSystemInfo file_system_info_; |
| 251 scoped_ptr<NotificationManagerInterface> notification_manager_; | 251 std::unique_ptr<NotificationManagerInterface> notification_manager_; |
| 252 scoped_ptr<RequestManager> request_manager_; | 252 std::unique_ptr<RequestManager> request_manager_; |
| 253 Watchers watchers_; | 253 Watchers watchers_; |
| 254 Queue watcher_queue_; | 254 Queue watcher_queue_; |
| 255 OpenedFiles opened_files_; | 255 OpenedFiles opened_files_; |
| 256 base::ObserverList<ProvidedFileSystemObserver> observers_; | 256 base::ObserverList<ProvidedFileSystemObserver> observers_; |
| 257 | 257 |
| 258 base::WeakPtrFactory<ProvidedFileSystem> weak_ptr_factory_; | 258 base::WeakPtrFactory<ProvidedFileSystem> weak_ptr_factory_; |
| 259 DISALLOW_COPY_AND_ASSIGN(ProvidedFileSystem); | 259 DISALLOW_COPY_AND_ASSIGN(ProvidedFileSystem); |
| 260 }; | 260 }; |
| 261 | 261 |
| 262 } // namespace file_system_provider | 262 } // namespace file_system_provider |
| 263 } // namespace chromeos | 263 } // namespace chromeos |
| 264 | 264 |
| 265 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_H_ | 265 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_H_ |
| OLD | NEW |