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_MEDIA_GALLERIES_GALLERY_WATCH_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_GALLERY_WATCH_MANAGER_H_ |
6 #define CHROME_BROWSER_MEDIA_GALLERIES_GALLERY_WATCH_MANAGER_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_GALLERY_WATCH_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 public storage_monitor::RemovableStorageObserver { | 38 public storage_monitor::RemovableStorageObserver { |
39 public: | 39 public: |
40 // On success, |error| is empty. | 40 // On success, |error| is empty. |
41 typedef base::Callback<void(const std::string& /* error */)> ResultCallback; | 41 typedef base::Callback<void(const std::string& /* error */)> ResultCallback; |
42 | 42 |
43 static const char kInvalidGalleryIDError[]; | 43 static const char kInvalidGalleryIDError[]; |
44 static const char kNoPermissionError[]; | 44 static const char kNoPermissionError[]; |
45 static const char kCouldNotWatchGalleryError[]; | 45 static const char kCouldNotWatchGalleryError[]; |
46 | 46 |
47 GalleryWatchManager(); | 47 GalleryWatchManager(); |
48 virtual ~GalleryWatchManager(); | 48 ~GalleryWatchManager() override; |
49 | 49 |
50 // Add or remove observer of change events - this is the only way to | 50 // Add or remove observer of change events - this is the only way to |
51 // get the result of the file watches. There can only be one observer per | 51 // get the result of the file watches. There can only be one observer per |
52 // browser context. | 52 // browser context. |
53 void AddObserver(content::BrowserContext* browser_context, | 53 void AddObserver(content::BrowserContext* browser_context, |
54 GalleryWatchManagerObserver* observer); | 54 GalleryWatchManagerObserver* observer); |
55 void RemoveObserver(content::BrowserContext* browser_context); | 55 void RemoveObserver(content::BrowserContext* browser_context); |
56 | 56 |
57 // Must be called when |browser_context| is shut down. | 57 // Must be called when |browser_context| is shut down. |
58 void ShutdownBrowserContext(content::BrowserContext* browser_context); | 58 void ShutdownBrowserContext(content::BrowserContext* browser_context); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // watch the path. | 116 // watch the path. |
117 void OnFileWatchActivated(const WatchOwner& owner, | 117 void OnFileWatchActivated(const WatchOwner& owner, |
118 const base::FilePath& path, | 118 const base::FilePath& path, |
119 const ResultCallback& callback, | 119 const ResultCallback& callback, |
120 bool success); | 120 bool success); |
121 | 121 |
122 // Called by FilePathWatcher on the UI thread on a change event for |path|. | 122 // Called by FilePathWatcher on the UI thread on a change event for |path|. |
123 void OnFilePathChanged(const base::FilePath& path, bool error); | 123 void OnFilePathChanged(const base::FilePath& path, bool error); |
124 | 124 |
125 // MediaGalleriesPreferences::GalleryChangeObserver implementation. | 125 // MediaGalleriesPreferences::GalleryChangeObserver implementation. |
126 virtual void OnPermissionRemoved(MediaGalleriesPreferences* pref, | 126 void OnPermissionRemoved(MediaGalleriesPreferences* pref, |
127 const std::string& extension_id, | 127 const std::string& extension_id, |
128 MediaGalleryPrefId pref_id) override; | 128 MediaGalleryPrefId pref_id) override; |
129 virtual void OnGalleryRemoved(MediaGalleriesPreferences* pref, | 129 void OnGalleryRemoved(MediaGalleriesPreferences* pref, |
130 MediaGalleryPrefId pref_id) override; | 130 MediaGalleryPrefId pref_id) override; |
131 | 131 |
132 // storage_monitor::RemovableStorageObserver implementation. | 132 // storage_monitor::RemovableStorageObserver implementation. |
133 virtual void OnRemovableStorageDetached( | 133 void OnRemovableStorageDetached( |
134 const storage_monitor::StorageInfo& info) override; | 134 const storage_monitor::StorageInfo& info) override; |
135 | 135 |
136 // True if the we are already observing the storage monitor. | 136 // True if the we are already observing the storage monitor. |
137 bool storage_monitor_observed_; | 137 bool storage_monitor_observed_; |
138 | 138 |
139 // MediaGalleriesPreferences we are currently observing. | 139 // MediaGalleriesPreferences we are currently observing. |
140 std::set<MediaGalleriesPreferences*> observed_preferences_; | 140 std::set<MediaGalleriesPreferences*> observed_preferences_; |
141 | 141 |
142 // All registered watches, keyed by WatchOwner. | 142 // All registered watches, keyed by WatchOwner. |
143 WatchesMap watches_; | 143 WatchesMap watches_; |
144 | 144 |
145 // Reverse mapping of watched paths to the set of owning WatchOwners. | 145 // Reverse mapping of watched paths to the set of owning WatchOwners. |
146 WatchedPaths watched_paths_; | 146 WatchedPaths watched_paths_; |
147 | 147 |
148 // Things that want to hear about gallery changes. | 148 // Things that want to hear about gallery changes. |
149 ObserverMap observers_; | 149 ObserverMap observers_; |
150 | 150 |
151 // Helper that does the watches on the FILE thread. | 151 // Helper that does the watches on the FILE thread. |
152 scoped_ptr<FileWatchManager> watch_manager_; | 152 scoped_ptr<FileWatchManager> watch_manager_; |
153 | 153 |
154 base::WeakPtrFactory<GalleryWatchManager> weak_factory_; | 154 base::WeakPtrFactory<GalleryWatchManager> weak_factory_; |
155 | 155 |
156 DISALLOW_COPY_AND_ASSIGN(GalleryWatchManager); | 156 DISALLOW_COPY_AND_ASSIGN(GalleryWatchManager); |
157 }; | 157 }; |
158 | 158 |
159 #endif // CHROME_BROWSER_MEDIA_GALLERIES_GALLERY_WATCH_MANAGER_H_ | 159 #endif // CHROME_BROWSER_MEDIA_GALLERIES_GALLERY_WATCH_MANAGER_H_ |
OLD | NEW |