| 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..b21c3dac37d13371df17c8a7f754c14d46da3c55 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 {
|
| +
|
| 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;
|
| +
|
| +// Wraps an ArcFileSystemOperationRunner::Observer so it is called on the IO
|
| +// thread.
|
| +class ObserverIOThreadWrapper
|
| + : 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);
|
| +};
|
|
|
| // 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
|
|
|