| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_THROTTLED_FILE_SYSTEM_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_THROTTLED_FILE_SYSTEM_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_THROTTLED_FILE_SYSTEM_H_ | 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_THROTTLED_FILE_SYSTEM_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <string> | 11 #include <string> |
| 11 #include <vector> | 12 #include <vector> |
| 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 "chrome/browser/chromeos/file_system_provider/abort_callback.h" | 17 #include "chrome/browser/chromeos/file_system_provider/abort_callback.h" |
| 18 #include "chrome/browser/chromeos/file_system_provider/provided_file_system.h" | 18 #include "chrome/browser/chromeos/file_system_provider/provided_file_system.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 "storage/browser/fileapi/async_file_util.h" | 22 #include "storage/browser/fileapi/async_file_util.h" |
| 23 #include "storage/browser/fileapi/watcher_manager.h" | 23 #include "storage/browser/fileapi/watcher_manager.h" |
| 24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 25 | 25 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 36 namespace chromeos { | 36 namespace chromeos { |
| 37 namespace file_system_provider { | 37 namespace file_system_provider { |
| 38 | 38 |
| 39 class Queue; | 39 class Queue; |
| 40 class RequestManager; | 40 class RequestManager; |
| 41 | 41 |
| 42 // Decorates ProvidedFileSystemInterface with throttling capabilities. | 42 // Decorates ProvidedFileSystemInterface with throttling capabilities. |
| 43 class ThrottledFileSystem : public ProvidedFileSystemInterface { | 43 class ThrottledFileSystem : public ProvidedFileSystemInterface { |
| 44 public: | 44 public: |
| 45 explicit ThrottledFileSystem( | 45 explicit ThrottledFileSystem( |
| 46 scoped_ptr<ProvidedFileSystemInterface> file_system); | 46 std::unique_ptr<ProvidedFileSystemInterface> file_system); |
| 47 ~ThrottledFileSystem() override; | 47 ~ThrottledFileSystem() override; |
| 48 | 48 |
| 49 // ProvidedFileSystemInterface overrides. | 49 // ProvidedFileSystemInterface overrides. |
| 50 AbortCallback RequestUnmount( | 50 AbortCallback RequestUnmount( |
| 51 const storage::AsyncFileUtil::StatusCallback& callback) override; | 51 const storage::AsyncFileUtil::StatusCallback& callback) override; |
| 52 AbortCallback GetMetadata(const base::FilePath& entry_path, | 52 AbortCallback GetMetadata(const base::FilePath& entry_path, |
| 53 MetadataFieldMask fields, | 53 MetadataFieldMask fields, |
| 54 const GetMetadataCallback& callback) override; | 54 const GetMetadataCallback& callback) override; |
| 55 AbortCallback GetActions(const std::vector<base::FilePath>& entry_paths, | 55 AbortCallback GetActions(const std::vector<base::FilePath>& entry_paths, |
| 56 const GetActionsCallback& callback) override; | 56 const GetActionsCallback& callback) override; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 const storage::AsyncFileUtil::StatusCallback& callback) override; | 116 const storage::AsyncFileUtil::StatusCallback& callback) override; |
| 117 const ProvidedFileSystemInfo& GetFileSystemInfo() const override; | 117 const ProvidedFileSystemInfo& GetFileSystemInfo() const override; |
| 118 RequestManager* GetRequestManager() override; | 118 RequestManager* GetRequestManager() override; |
| 119 Watchers* GetWatchers() override; | 119 Watchers* GetWatchers() override; |
| 120 const OpenedFiles& GetOpenedFiles() const override; | 120 const OpenedFiles& GetOpenedFiles() const override; |
| 121 void AddObserver(ProvidedFileSystemObserver* observer) override; | 121 void AddObserver(ProvidedFileSystemObserver* observer) override; |
| 122 void RemoveObserver(ProvidedFileSystemObserver* observer) override; | 122 void RemoveObserver(ProvidedFileSystemObserver* observer) override; |
| 123 void Notify(const base::FilePath& entry_path, | 123 void Notify(const base::FilePath& entry_path, |
| 124 bool recursive, | 124 bool recursive, |
| 125 storage::WatcherManager::ChangeType change_type, | 125 storage::WatcherManager::ChangeType change_type, |
| 126 scoped_ptr<ProvidedFileSystemObserver::Changes> changes, | 126 std::unique_ptr<ProvidedFileSystemObserver::Changes> changes, |
| 127 const std::string& tag, | 127 const std::string& tag, |
| 128 const storage::AsyncFileUtil::StatusCallback& callback) override; | 128 const storage::AsyncFileUtil::StatusCallback& callback) override; |
| 129 void Configure( | 129 void Configure( |
| 130 const storage::AsyncFileUtil::StatusCallback& callback) override; | 130 const storage::AsyncFileUtil::StatusCallback& callback) override; |
| 131 base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() override; | 131 base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() override; |
| 132 | 132 |
| 133 private: | 133 private: |
| 134 // Called when an operation enqueued with |queue_token| is aborted. | 134 // Called when an operation enqueued with |queue_token| is aborted. |
| 135 void Abort(int queue_token); | 135 void Abort(int queue_token); |
| 136 | 136 |
| 137 // Called when opening a file is completed with either a success or an error. | 137 // Called when opening a file is completed with either a success or an error. |
| 138 void OnOpenFileCompleted(int queue_token, | 138 void OnOpenFileCompleted(int queue_token, |
| 139 const OpenFileCallback& callback, | 139 const OpenFileCallback& callback, |
| 140 int file_handle, | 140 int file_handle, |
| 141 base::File::Error result); | 141 base::File::Error result); |
| 142 | 142 |
| 143 // Called when closing a file is completed with either a success or an error. | 143 // Called when closing a file is completed with either a success or an error. |
| 144 void OnCloseFileCompleted( | 144 void OnCloseFileCompleted( |
| 145 int file_handle, | 145 int file_handle, |
| 146 const storage::AsyncFileUtil::StatusCallback& callback, | 146 const storage::AsyncFileUtil::StatusCallback& callback, |
| 147 base::File::Error result); | 147 base::File::Error result); |
| 148 | 148 |
| 149 scoped_ptr<ProvidedFileSystemInterface> file_system_; | 149 std::unique_ptr<ProvidedFileSystemInterface> file_system_; |
| 150 scoped_ptr<Queue> open_queue_; | 150 std::unique_ptr<Queue> open_queue_; |
| 151 | 151 |
| 152 // Map from file handles to open queue tokens. | 152 // Map from file handles to open queue tokens. |
| 153 std::map<int, int> opened_files_; | 153 std::map<int, int> opened_files_; |
| 154 | 154 |
| 155 base::WeakPtrFactory<ThrottledFileSystem> weak_ptr_factory_; | 155 base::WeakPtrFactory<ThrottledFileSystem> weak_ptr_factory_; |
| 156 DISALLOW_COPY_AND_ASSIGN(ThrottledFileSystem); | 156 DISALLOW_COPY_AND_ASSIGN(ThrottledFileSystem); |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 } // namespace file_system_provider | 159 } // namespace file_system_provider |
| 160 } // namespace chromeos | 160 } // namespace chromeos |
| 161 | 161 |
| 162 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_THROTTLED_FILE_SYSTEM_H_ | 162 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_THROTTLED_FILE_SYSTEM_H_ |
| OLD | NEW |