OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_H_ |
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_H_ | 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" | 14 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" |
15 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" | 15 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" |
16 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_obse
rver.h" | 16 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_obse
rver.h" |
17 #include "chrome/browser/chromeos/file_system_provider/request_manager.h" | 17 #include "chrome/browser/chromeos/file_system_provider/request_manager.h" |
18 #include "storage/browser/fileapi/async_file_util.h" | 18 #include "storage/browser/fileapi/async_file_util.h" |
| 19 #include "url/gurl.h" |
19 | 20 |
20 class Profile; | 21 class Profile; |
21 | 22 |
22 namespace net { | 23 namespace net { |
23 class IOBuffer; | 24 class IOBuffer; |
24 } // namespace net | 25 } // namespace net |
25 | 26 |
26 namespace base { | 27 namespace base { |
27 class FilePath; | 28 class FilePath; |
28 } // namespace base | 29 } // namespace base |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 const base::FilePath& file_path, | 131 const base::FilePath& file_path, |
131 int64 length, | 132 int64 length, |
132 const storage::AsyncFileUtil::StatusCallback& callback) override; | 133 const storage::AsyncFileUtil::StatusCallback& callback) override; |
133 virtual AbortCallback WriteFile( | 134 virtual AbortCallback WriteFile( |
134 int file_handle, | 135 int file_handle, |
135 net::IOBuffer* buffer, | 136 net::IOBuffer* buffer, |
136 int64 offset, | 137 int64 offset, |
137 int length, | 138 int length, |
138 const storage::AsyncFileUtil::StatusCallback& callback) override; | 139 const storage::AsyncFileUtil::StatusCallback& callback) override; |
139 virtual AbortCallback ObserveDirectory( | 140 virtual AbortCallback ObserveDirectory( |
| 141 const GURL& origin, |
140 const base::FilePath& directory_path, | 142 const base::FilePath& directory_path, |
141 bool recursive, | 143 bool recursive, |
| 144 bool persistent, |
142 const storage::AsyncFileUtil::StatusCallback& callback) override; | 145 const storage::AsyncFileUtil::StatusCallback& callback) override; |
143 virtual void UnobserveEntry( | 146 virtual void UnobserveEntry( |
| 147 const GURL& origin, |
144 const base::FilePath& entry_path, | 148 const base::FilePath& entry_path, |
145 bool recursive, | 149 bool recursive, |
146 const storage::AsyncFileUtil::StatusCallback& callback) override; | 150 const storage::AsyncFileUtil::StatusCallback& callback) override; |
147 virtual const ProvidedFileSystemInfo& GetFileSystemInfo() const override; | 151 virtual const ProvidedFileSystemInfo& GetFileSystemInfo() const override; |
148 virtual RequestManager* GetRequestManager() override; | 152 virtual RequestManager* GetRequestManager() override; |
149 virtual ObservedEntries* GetObservedEntries() override; | 153 virtual ObservedEntries* GetObservedEntries() override; |
150 virtual void AddObserver(ProvidedFileSystemObserver* observer) override; | 154 virtual void AddObserver(ProvidedFileSystemObserver* observer) override; |
151 virtual void RemoveObserver(ProvidedFileSystemObserver* observer) override; | 155 virtual void RemoveObserver(ProvidedFileSystemObserver* observer) override; |
152 virtual bool Notify(const base::FilePath& observed_path, | 156 virtual bool Notify(const base::FilePath& observed_path, |
153 bool recursive, | 157 bool recursive, |
154 ProvidedFileSystemObserver::ChangeType change_type, | 158 ProvidedFileSystemObserver::ChangeType change_type, |
155 scoped_ptr<ProvidedFileSystemObserver::Changes> changes, | 159 scoped_ptr<ProvidedFileSystemObserver::Changes> changes, |
156 const std::string& tag) override; | 160 const std::string& tag) override; |
157 virtual base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() override; | 161 virtual base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() override; |
158 | 162 |
159 private: | 163 private: |
160 // Aborts an operation executed with a request id equal to | 164 // Aborts an operation executed with a request id equal to |
161 // |operation_request_id|. The request is removed immediately on the C++ side | 165 // |operation_request_id|. The request is removed immediately on the C++ side |
162 // despite being handled by the providing extension or not. | 166 // despite being handled by the providing extension or not. |
163 void Abort(int operation_request_id, | 167 void Abort(int operation_request_id, |
164 const storage::AsyncFileUtil::StatusCallback& callback); | 168 const storage::AsyncFileUtil::StatusCallback& callback); |
165 | 169 |
166 // Called when a directory becomes watched successfully. | 170 // Called when observing a directory process is completed with either success |
| 171 // or en error. |
167 void OnObserveDirectoryCompleted( | 172 void OnObserveDirectoryCompleted( |
| 173 const GURL& origin, |
168 const base::FilePath& directory_path, | 174 const base::FilePath& directory_path, |
169 bool recursive, | 175 bool recursive, |
| 176 bool persistent, |
170 const storage::AsyncFileUtil::StatusCallback& callback, | 177 const storage::AsyncFileUtil::StatusCallback& callback, |
171 base::File::Error result); | 178 base::File::Error result); |
172 | 179 |
173 // Called when all observers finished handling the change notification. It | 180 // Called when all observers finished handling the change notification. It |
174 // updates the tag from |last_tag| to |tag| for the entry at |observed_path|. | 181 // updates the tag from |last_tag| to |tag| for the entry at |observed_path|. |
175 void OnNotifyCompleted( | 182 void OnNotifyCompleted( |
176 const base::FilePath& observed_path, | 183 const base::FilePath& observed_path, |
177 bool recursive, | 184 bool recursive, |
178 ProvidedFileSystemObserver::ChangeType change_type, | 185 ProvidedFileSystemObserver::ChangeType change_type, |
179 scoped_ptr<ProvidedFileSystemObserver::Changes> changes, | 186 scoped_ptr<ProvidedFileSystemObserver::Changes> changes, |
180 const std::string& last_tag, | 187 const std::string& last_tag, |
181 const std::string& tag); | 188 const std::string& tag); |
182 | 189 |
183 Profile* profile_; // Not owned. | 190 Profile* profile_; // Not owned. |
184 extensions::EventRouter* event_router_; // Not owned. May be NULL. | 191 extensions::EventRouter* event_router_; // Not owned. May be NULL. |
185 ProvidedFileSystemInfo file_system_info_; | 192 ProvidedFileSystemInfo file_system_info_; |
186 scoped_ptr<NotificationManagerInterface> notification_manager_; | 193 scoped_ptr<NotificationManagerInterface> notification_manager_; |
187 scoped_ptr<RequestManager> request_manager_; | 194 scoped_ptr<RequestManager> request_manager_; |
188 ObservedEntries observed_entries_; | 195 ObservedEntries observed_entries_; |
189 ObserverList<ProvidedFileSystemObserver> observers_; | 196 ObserverList<ProvidedFileSystemObserver> observers_; |
190 | 197 |
191 base::WeakPtrFactory<ProvidedFileSystem> weak_ptr_factory_; | 198 base::WeakPtrFactory<ProvidedFileSystem> weak_ptr_factory_; |
192 DISALLOW_COPY_AND_ASSIGN(ProvidedFileSystem); | 199 DISALLOW_COPY_AND_ASSIGN(ProvidedFileSystem); |
193 }; | 200 }; |
194 | 201 |
195 } // namespace file_system_provider | 202 } // namespace file_system_provider |
196 } // namespace chromeos | 203 } // namespace chromeos |
197 | 204 |
198 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_H_ | 205 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_H_ |
OLD | NEW |