Chromium Code Reviews| 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..a3d81b368e82b5f99dbe604b5a13440cebc2131f 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,13 @@ |
| #include <stddef.h> |
| #include <stdint.h> |
| +#include <memory> |
| +#include <set> |
| #include <string> |
| +#include <vector> |
| #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 +28,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 +88,37 @@ class FileManagerPrivateGrantAccessFunction : public UIThreadExtensionFunction { |
| // directories. |
| class FileWatchFunctionBase : public LoggedAsyncExtensionFunction { |
| public: |
| + using ResponseCallback = base::Callback<void(bool success)>; |
|
hidehiko
2017/02/23 11:05:58
#include "base/callback.h" looks missing.
Shuhei Takahashi
2017/02/24 05:13:25
Done.
|
| + |
| // 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 +133,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 +156,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. |