| Index: chrome/browser/chromeos/extensions/file_manager/private_api_file_system.h
|
| diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.h b/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.h
|
| index 21b4f23c00bd1472cce51f6a4d1551f102ad5939..e2e75c5b6cc40d6a1a79e4c604abb6abf99707c3 100644
|
| --- a/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.h
|
| +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.h
|
| @@ -10,9 +10,14 @@
|
| #include <stddef.h>
|
| #include <stdint.h>
|
|
|
| +#include <memory>
|
| +#include <set>
|
| #include <string>
|
| +#include <vector>
|
|
|
| +#include "base/callback_forward.h"
|
| #include "base/macros.h"
|
| +#include "base/memory/weak_ptr.h"
|
| #include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h"
|
| #include "chrome/browser/extensions/chrome_extension_function.h"
|
| #include "chrome/browser/extensions/chrome_extension_function_details.h"
|
| @@ -24,9 +29,11 @@
|
| namespace storage {
|
| class FileSystemContext;
|
| class FileSystemURL;
|
| +class WatcherManager;
|
| } // namespace storage
|
|
|
| namespace file_manager {
|
| +class EventRouter;
|
| namespace util {
|
| struct EntryDefinition;
|
| typedef std::vector<EntryDefinition> EntryDefinitionList;
|
| @@ -82,20 +89,37 @@ class FileManagerPrivateGrantAccessFunction : public UIThreadExtensionFunction {
|
| // directories.
|
| class FileWatchFunctionBase : public LoggedAsyncExtensionFunction {
|
| public:
|
| + using ResponseCallback = base::Callback<void(bool success)>;
|
| +
|
| // Calls SendResponse() with |success| converted to base::Value.
|
| void Respond(bool success);
|
|
|
| protected:
|
| ~FileWatchFunctionBase() override {}
|
|
|
| - // Performs a file watch operation (ex. adds or removes a file watch).
|
| - virtual void PerformFileWatchOperation(
|
| + // Performs a file watch operation (ex. adds or removes a file watch) on
|
| + // the IO thread with storage::WatcherManager.
|
| + virtual void PerformFileWatchOperationOnIOThread(
|
| scoped_refptr<storage::FileSystemContext> file_system_context,
|
| + storage::WatcherManager* watcher_manager,
|
| + const storage::FileSystemURL& file_system_url,
|
| + base::WeakPtr<file_manager::EventRouter> event_router) = 0;
|
| +
|
| + // Performs a file watch operation (ex. adds or removes a file watch) on
|
| + // the UI thread with file_manager::EventRouter. This is a fallback operation
|
| + // called only when WatcherManager is unavailable.
|
| + virtual void PerformFallbackFileWatchOperationOnUIThread(
|
| const storage::FileSystemURL& file_system_url,
|
| - const std::string& extension_id) = 0;
|
| + base::WeakPtr<file_manager::EventRouter> event_router) = 0;
|
|
|
| // AsyncExtensionFunction overrides.
|
| bool RunAsync() override;
|
| +
|
| + private:
|
| + void RunAsyncOnIOThread(
|
| + scoped_refptr<storage::FileSystemContext> file_system_context,
|
| + const storage::FileSystemURL& file_system_url,
|
| + base::WeakPtr<file_manager::EventRouter> event_router);
|
| };
|
|
|
| // Implements the chrome.fileManagerPrivate.addFileWatch method.
|
| @@ -110,10 +134,14 @@ class FileManagerPrivateInternalAddFileWatchFunction
|
| ~FileManagerPrivateInternalAddFileWatchFunction() override {}
|
|
|
| // FileWatchFunctionBase override.
|
| - void PerformFileWatchOperation(
|
| + void PerformFileWatchOperationOnIOThread(
|
| scoped_refptr<storage::FileSystemContext> file_system_context,
|
| + storage::WatcherManager* watcher_manager,
|
| const storage::FileSystemURL& file_system_url,
|
| - const std::string& extension_id) override;
|
| + base::WeakPtr<file_manager::EventRouter> event_router) override;
|
| + void PerformFallbackFileWatchOperationOnUIThread(
|
| + const storage::FileSystemURL& file_system_url,
|
| + base::WeakPtr<file_manager::EventRouter> event_router) override;
|
| };
|
|
|
|
|
| @@ -129,10 +157,14 @@ class FileManagerPrivateInternalRemoveFileWatchFunction
|
| ~FileManagerPrivateInternalRemoveFileWatchFunction() override {}
|
|
|
| // FileWatchFunctionBase override.
|
| - void PerformFileWatchOperation(
|
| + void PerformFileWatchOperationOnIOThread(
|
| scoped_refptr<storage::FileSystemContext> file_system_context,
|
| + storage::WatcherManager* watcher_manager,
|
| + const storage::FileSystemURL& file_system_url,
|
| + base::WeakPtr<file_manager::EventRouter> event_router) override;
|
| + void PerformFallbackFileWatchOperationOnUIThread(
|
| const storage::FileSystemURL& file_system_url,
|
| - const std::string& extension_id) override;
|
| + base::WeakPtr<file_manager::EventRouter> event_router) override;
|
| };
|
|
|
| // Implements the chrome.fileManagerPrivate.getSizeStats method.
|
|
|