Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/private_api_file_system.h

Issue 2712613002: Call WatcherManager functions on the IO thread. (Closed)
Patch Set: Updated comments as per mtomasz's request. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // This file provides file system related API functions. 5 // This file provides file system related API functions.
6 6
7 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_FILE_SYSTEM_ H_ 7 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_FILE_SYSTEM_ H_
8 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_FILE_SYSTEM_ H_ 8 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_FILE_SYSTEM_ H_
9 9
10 #include <stddef.h> 10 #include <stddef.h>
11 #include <stdint.h> 11 #include <stdint.h>
12 12
13 #include <memory>
14 #include <set>
13 #include <string> 15 #include <string>
16 #include <vector>
14 17
15 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/memory/weak_ptr.h"
16 #include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h" 20 #include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h"
17 #include "chrome/browser/extensions/chrome_extension_function.h" 21 #include "chrome/browser/extensions/chrome_extension_function.h"
18 #include "chrome/browser/extensions/chrome_extension_function_details.h" 22 #include "chrome/browser/extensions/chrome_extension_function_details.h"
19 #include "components/drive/file_errors.h" 23 #include "components/drive/file_errors.h"
20 #include "device/media_transfer_protocol/mtp_storage_info.pb.h" 24 #include "device/media_transfer_protocol/mtp_storage_info.pb.h"
21 #include "extensions/browser/extension_function.h" 25 #include "extensions/browser/extension_function.h"
22 #include "storage/browser/fileapi/file_system_url.h" 26 #include "storage/browser/fileapi/file_system_url.h"
23 27
24 namespace storage { 28 namespace storage {
25 class FileSystemContext; 29 class FileSystemContext;
26 class FileSystemURL; 30 class FileSystemURL;
31 class WatcherManager;
27 } // namespace storage 32 } // namespace storage
28 33
29 namespace file_manager { 34 namespace file_manager {
35 class EventRouter;
30 namespace util { 36 namespace util {
31 struct EntryDefinition; 37 struct EntryDefinition;
32 typedef std::vector<EntryDefinition> EntryDefinitionList; 38 typedef std::vector<EntryDefinition> EntryDefinitionList;
33 } // namespace util 39 } // namespace util
34 } // namespace file_manager 40 } // namespace file_manager
35 41
36 namespace drive { 42 namespace drive {
37 namespace util { 43 namespace util {
38 class FileStreamMd5Digester; 44 class FileStreamMd5Digester;
39 } // namespace util 45 } // namespace util
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 DISALLOW_COPY_AND_ASSIGN(FileManagerPrivateGrantAccessFunction); 81 DISALLOW_COPY_AND_ASSIGN(FileManagerPrivateGrantAccessFunction);
76 }; 82 };
77 83
78 // Base class for FileManagerPrivateInternalAddFileWatchFunction and 84 // Base class for FileManagerPrivateInternalAddFileWatchFunction and
79 // FileManagerPrivateInternalRemoveFileWatchFunction. Although it's called 85 // FileManagerPrivateInternalRemoveFileWatchFunction. Although it's called
80 // "FileWatch", 86 // "FileWatch",
81 // the class and its sub classes are used only for watching changes in 87 // the class and its sub classes are used only for watching changes in
82 // directories. 88 // directories.
83 class FileWatchFunctionBase : public LoggedAsyncExtensionFunction { 89 class FileWatchFunctionBase : public LoggedAsyncExtensionFunction {
84 public: 90 public:
91 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.
92
85 // Calls SendResponse() with |success| converted to base::Value. 93 // Calls SendResponse() with |success| converted to base::Value.
86 void Respond(bool success); 94 void Respond(bool success);
87 95
88 protected: 96 protected:
89 ~FileWatchFunctionBase() override {} 97 ~FileWatchFunctionBase() override {}
90 98
91 // Performs a file watch operation (ex. adds or removes a file watch). 99 // Performs a file watch operation (ex. adds or removes a file watch) on
92 virtual void PerformFileWatchOperation( 100 // the IO thread with storage::WatcherManager.
101 virtual void PerformFileWatchOperationOnIOThread(
93 scoped_refptr<storage::FileSystemContext> file_system_context, 102 scoped_refptr<storage::FileSystemContext> file_system_context,
103 storage::WatcherManager* watcher_manager,
94 const storage::FileSystemURL& file_system_url, 104 const storage::FileSystemURL& file_system_url,
95 const std::string& extension_id) = 0; 105 base::WeakPtr<file_manager::EventRouter> event_router) = 0;
106
107 // Performs a file watch operation (ex. adds or removes a file watch) on
108 // the UI thread with file_manager::EventRouter. This is a fallback operation
109 // called only when WatcherManager is unavailable.
110 virtual void PerformFallbackFileWatchOperationOnUIThread(
111 const storage::FileSystemURL& file_system_url,
112 base::WeakPtr<file_manager::EventRouter> event_router) = 0;
96 113
97 // AsyncExtensionFunction overrides. 114 // AsyncExtensionFunction overrides.
98 bool RunAsync() override; 115 bool RunAsync() override;
116
117 private:
118 void RunAsyncOnIOThread(
119 scoped_refptr<storage::FileSystemContext> file_system_context,
120 const storage::FileSystemURL& file_system_url,
121 base::WeakPtr<file_manager::EventRouter> event_router);
99 }; 122 };
100 123
101 // Implements the chrome.fileManagerPrivate.addFileWatch method. 124 // Implements the chrome.fileManagerPrivate.addFileWatch method.
102 // Starts watching changes in directories. 125 // Starts watching changes in directories.
103 class FileManagerPrivateInternalAddFileWatchFunction 126 class FileManagerPrivateInternalAddFileWatchFunction
104 : public FileWatchFunctionBase { 127 : public FileWatchFunctionBase {
105 public: 128 public:
106 DECLARE_EXTENSION_FUNCTION("fileManagerPrivateInternal.addFileWatch", 129 DECLARE_EXTENSION_FUNCTION("fileManagerPrivateInternal.addFileWatch",
107 FILEMANAGERPRIVATEINTERNAL_ADDFILEWATCH) 130 FILEMANAGERPRIVATEINTERNAL_ADDFILEWATCH)
108 131
109 protected: 132 protected:
110 ~FileManagerPrivateInternalAddFileWatchFunction() override {} 133 ~FileManagerPrivateInternalAddFileWatchFunction() override {}
111 134
112 // FileWatchFunctionBase override. 135 // FileWatchFunctionBase override.
113 void PerformFileWatchOperation( 136 void PerformFileWatchOperationOnIOThread(
114 scoped_refptr<storage::FileSystemContext> file_system_context, 137 scoped_refptr<storage::FileSystemContext> file_system_context,
138 storage::WatcherManager* watcher_manager,
115 const storage::FileSystemURL& file_system_url, 139 const storage::FileSystemURL& file_system_url,
116 const std::string& extension_id) override; 140 base::WeakPtr<file_manager::EventRouter> event_router) override;
141 void PerformFallbackFileWatchOperationOnUIThread(
142 const storage::FileSystemURL& file_system_url,
143 base::WeakPtr<file_manager::EventRouter> event_router) override;
117 }; 144 };
118 145
119 146
120 // Implements the chrome.fileManagerPrivate.removeFileWatch method. 147 // Implements the chrome.fileManagerPrivate.removeFileWatch method.
121 // Stops watching changes in directories. 148 // Stops watching changes in directories.
122 class FileManagerPrivateInternalRemoveFileWatchFunction 149 class FileManagerPrivateInternalRemoveFileWatchFunction
123 : public FileWatchFunctionBase { 150 : public FileWatchFunctionBase {
124 public: 151 public:
125 DECLARE_EXTENSION_FUNCTION("fileManagerPrivateInternal.removeFileWatch", 152 DECLARE_EXTENSION_FUNCTION("fileManagerPrivateInternal.removeFileWatch",
126 FILEMANAGERPRIVATEINTERNAL_REMOVEFILEWATCH) 153 FILEMANAGERPRIVATEINTERNAL_REMOVEFILEWATCH)
127 154
128 protected: 155 protected:
129 ~FileManagerPrivateInternalRemoveFileWatchFunction() override {} 156 ~FileManagerPrivateInternalRemoveFileWatchFunction() override {}
130 157
131 // FileWatchFunctionBase override. 158 // FileWatchFunctionBase override.
132 void PerformFileWatchOperation( 159 void PerformFileWatchOperationOnIOThread(
133 scoped_refptr<storage::FileSystemContext> file_system_context, 160 scoped_refptr<storage::FileSystemContext> file_system_context,
161 storage::WatcherManager* watcher_manager,
134 const storage::FileSystemURL& file_system_url, 162 const storage::FileSystemURL& file_system_url,
135 const std::string& extension_id) override; 163 base::WeakPtr<file_manager::EventRouter> event_router) override;
164 void PerformFallbackFileWatchOperationOnUIThread(
165 const storage::FileSystemURL& file_system_url,
166 base::WeakPtr<file_manager::EventRouter> event_router) override;
136 }; 167 };
137 168
138 // Implements the chrome.fileManagerPrivate.getSizeStats method. 169 // Implements the chrome.fileManagerPrivate.getSizeStats method.
139 class FileManagerPrivateGetSizeStatsFunction 170 class FileManagerPrivateGetSizeStatsFunction
140 : public LoggedAsyncExtensionFunction { 171 : public LoggedAsyncExtensionFunction {
141 public: 172 public:
142 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.getSizeStats", 173 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.getSizeStats",
143 FILEMANAGERPRIVATE_GETSIZESTATS) 174 FILEMANAGERPRIVATE_GETSIZESTATS)
144 175
145 protected: 176 protected:
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 373
343 void OnDirectorySizeRetrieved(int64_t size); 374 void OnDirectorySizeRetrieved(int64_t size);
344 375
345 // AsyncExtensionFunction overrides 376 // AsyncExtensionFunction overrides
346 bool RunAsync() override; 377 bool RunAsync() override;
347 }; 378 };
348 379
349 } // namespace extensions 380 } // namespace extensions
350 381
351 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_FILE_SYST EM_H_ 382 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_FILE_SYST EM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698