| 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_OBSERV
ER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_OBSERV
ER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_OBSERV
ER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_OBSERV
ER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "chrome/browser/chromeos/file_system_provider/watcher.h" | 13 #include "chrome/browser/chromeos/file_system_provider/watcher.h" |
| 14 #include "storage/browser/fileapi/watcher_manager.h" |
| 14 | 15 |
| 15 namespace chromeos { | 16 namespace chromeos { |
| 16 namespace file_system_provider { | 17 namespace file_system_provider { |
| 17 | 18 |
| 18 class ProvidedFileSystemInfo; | 19 class ProvidedFileSystemInfo; |
| 19 class RequestManager; | 20 class RequestManager; |
| 20 | 21 |
| 21 // Observer class to be notified about changes happened to the provided file | 22 // Observer class to be notified about changes happened to the provided file |
| 22 // system, including watched entries. | 23 // system, including watched entries. |
| 23 class ProvidedFileSystemObserver { | 24 class ProvidedFileSystemObserver { |
| 24 public: | 25 public: |
| 25 struct Change; | 26 struct Change; |
| 26 | 27 |
| 27 // Type of a change to a watched entry. | |
| 28 enum ChangeType { CHANGED, DELETED }; | |
| 29 | |
| 30 // Lust of changes. | 28 // Lust of changes. |
| 31 typedef std::vector<Change> Changes; | 29 typedef std::vector<Change> Changes; |
| 32 | 30 |
| 33 // Describes a change related to a watched entry. | 31 // Describes a change related to a watched entry. |
| 34 struct Change { | 32 struct Change { |
| 35 Change(); | 33 Change(); |
| 36 ~Change(); | 34 ~Change(); |
| 37 | 35 |
| 38 base::FilePath entry_path; | 36 base::FilePath entry_path; |
| 39 ChangeType change_type; | 37 storage::WatcherManager::ChangeType change_type; |
| 40 }; | 38 }; |
| 41 | 39 |
| 42 // Called when a watched entry is changed, including removals. |callback| | 40 // Called when a watched entry is changed, including removals. |callback| |
| 43 // *must* be called after the entry change is handled. Once all observers | 41 // *must* be called after the entry change is handled. Once all observers |
| 44 // call the callback, the tag will be updated and OnWatcherTagUpdated | 42 // call the callback, the tag will be updated and OnWatcherTagUpdated |
| 45 // called. The reference to |changes| is valid at least as long as |callback|. | 43 // called. The reference to |changes| is valid at least as long as |callback|. |
| 46 virtual void OnWatcherChanged(const ProvidedFileSystemInfo& file_system_info, | 44 virtual void OnWatcherChanged(const ProvidedFileSystemInfo& file_system_info, |
| 47 const Watcher& watcher, | 45 const Watcher& watcher, |
| 48 ChangeType change_type, | 46 storage::WatcherManager::ChangeType change_type, |
| 49 const Changes& changes, | 47 const Changes& changes, |
| 50 const base::Closure& callback) = 0; | 48 const base::Closure& callback) = 0; |
| 51 | 49 |
| 52 // Called after the tag value is updated for the watcher. | 50 // Called after the tag value is updated for the watcher. |
| 53 virtual void OnWatcherTagUpdated( | 51 virtual void OnWatcherTagUpdated( |
| 54 const ProvidedFileSystemInfo& file_system_info, | 52 const ProvidedFileSystemInfo& file_system_info, |
| 55 const Watcher& watcher) = 0; | 53 const Watcher& watcher) = 0; |
| 56 | 54 |
| 57 // Called after the list of watchers is changed. | 55 // Called after the list of watchers is changed. |
| 58 virtual void OnWatcherListChanged( | 56 virtual void OnWatcherListChanged( |
| 59 const ProvidedFileSystemInfo& file_system_info, | 57 const ProvidedFileSystemInfo& file_system_info, |
| 60 const Watchers& watchers) = 0; | 58 const Watchers& watchers) = 0; |
| 61 }; | 59 }; |
| 62 | 60 |
| 63 } // namespace file_system_provider | 61 } // namespace file_system_provider |
| 64 } // namespace chromeos | 62 } // namespace chromeos |
| 65 | 63 |
| 66 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_OBS
ERVER_H_ | 64 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_OBS
ERVER_H_ |
| OLD | NEW |