Chromium Code Reviews| Index: chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner_util.h |
| diff --git a/chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner_util.h b/chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner_util.h |
| index 98740faa66260af6b9443bb88d49fdc2432ba3f7..e825a0c4a593063963a358cc8dd3f6cb07a26b08 100644 |
| --- a/chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner_util.h |
| +++ b/chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner_util.h |
| @@ -7,22 +7,62 @@ |
| #include <string> |
| -#include "components/arc/common/file_system.mojom.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner.h" |
| class GURL; |
| namespace arc { |
| + |
| +// Wraps an ArcFileSystemOperationRunner::Observer so it is called on the IO |
| +// thread. |
| +class ObserverIOThreadWrapper |
|
hidehiko
2017/03/02 14:43:47
Because here in namespace arc, and we have many Ob
Shuhei Takahashi
2017/03/03 04:22:15
Makes sense. I've moved the class to arc::file_sys
|
| + : public base::RefCountedThreadSafe<ObserverIOThreadWrapper>, |
| + public ArcFileSystemOperationRunner::Observer { |
| + public: |
| + explicit ObserverIOThreadWrapper( |
| + ArcFileSystemOperationRunner::Observer* underlying_observer); |
| + |
| + // Disables the observer. After calling this function, the underlying observer |
| + // will never be called. |
| + // This function should be called on the IO thread. |
| + void Disable(); |
| + |
| + // ArcFileSystemOperationRunner::Observer overrides: |
| + void OnWatchersCleared() override; |
| + |
| + private: |
| + friend class base::RefCountedThreadSafe<ObserverIOThreadWrapper>; |
| + |
| + ~ObserverIOThreadWrapper() override; |
| + |
| + void OnWatchersClearedOnIOThread(); |
| + |
| + ArcFileSystemOperationRunner::Observer* const underlying_observer_; |
| + |
| + // If set to true, |observer_| will not be called. This variable should be |
| + // accessed only on the IO thread. |
| + bool disabled_ = false; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ObserverIOThreadWrapper); |
| +}; |
| + |
| namespace file_system_operation_runner_util { |
| -using GetFileSizeCallback = mojom::FileSystemInstance::GetFileSizeCallback; |
| +using GetFileSizeCallback = ArcFileSystemOperationRunner::GetFileSizeCallback; |
| using OpenFileToReadCallback = |
| - mojom::FileSystemInstance::OpenFileToReadCallback; |
| -using GetDocumentCallback = mojom::FileSystemInstance::GetDocumentCallback; |
| + ArcFileSystemOperationRunner::OpenFileToReadCallback; |
| +using GetDocumentCallback = ArcFileSystemOperationRunner::GetDocumentCallback; |
| using GetChildDocumentsCallback = |
| - mojom::FileSystemInstance::GetChildDocumentsCallback; |
| + ArcFileSystemOperationRunner::GetChildDocumentsCallback; |
| +using AddWatcherCallback = ArcFileSystemOperationRunner::AddWatcherCallback; |
| +using RemoveWatcherCallback = |
| + ArcFileSystemOperationRunner::RemoveWatcherCallback; |
| +using WatcherCallback = ArcFileSystemOperationRunner::WatcherCallback; |
| // Utility functions to post a task to run ArcFileSystemOperationRunner methods. |
| -// These functions must be called on the IO thread. |
| +// These functions must be called on the IO thread. Callbacks and observers will |
| +// be called on the IO thread. |
| void GetFileSizeOnIOThread(const GURL& url, |
| const GetFileSizeCallback& callback); |
| void OpenFileToReadOnIOThread(const GURL& url, |
| @@ -33,6 +73,14 @@ void GetDocumentOnIOThread(const std::string& authority, |
| void GetChildDocumentsOnIOThread(const std::string& authority, |
| const std::string& parent_document_id, |
| const GetChildDocumentsCallback& callback); |
| +void AddWatcherOnIOThread(const std::string& authority, |
| + const std::string& document_id, |
| + const WatcherCallback& watcher_callback, |
| + const AddWatcherCallback& callback); |
| +void RemoveWatcherOnIOThread(int64_t watcher_id, |
| + const RemoveWatcherCallback& callback); |
| +void AddObserverOnIOThread(scoped_refptr<ObserverIOThreadWrapper> observer); |
| +void RemoveObserverOnIOThread(scoped_refptr<ObserverIOThreadWrapper> observer); |
| } // namespace file_system_operation_runner_util |
| } // namespace arc |