| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Manages all the gallery file watchers for the associated profile. This class | 5 // Manages all the gallery file watchers for the associated profile. This class |
| 6 // lives on the file thread. This class is instantiated per profile. This | 6 // lives on the file thread. This class is instantiated per profile. This |
| 7 // is temporary and will be moved to a permanent, public place in the near | 7 // is temporary and will be moved to a permanent, public place in the near |
| 8 // future. Please refer to crbug.com/166950 for more details. | 8 // future. Please refer to crbug.com/166950 for more details. |
| 9 | 9 |
| 10 #ifndef CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_MANA
GER_H_ | 10 #ifndef CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_MANA
GER_H_ |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // Notifies about the profile shutdown event. | 34 // Notifies about the profile shutdown event. |
| 35 static void OnProfileShutdown(void* profile_id); | 35 static void OnProfileShutdown(void* profile_id); |
| 36 | 36 |
| 37 // Sets up a gallery watch for the extension specified by the |extension_id|. | 37 // Sets up a gallery watch for the extension specified by the |extension_id|. |
| 38 // |profile_id| specifies the extension profile identifier. | 38 // |profile_id| specifies the extension profile identifier. |
| 39 // |gallery_id| specifies the gallery identifier. | 39 // |gallery_id| specifies the gallery identifier. |
| 40 // |watch_path| specifies the absolute gallery path. | 40 // |watch_path| specifies the absolute gallery path. |
| 41 // Returns true, if the watch setup operation was successful. | 41 // Returns true, if the watch setup operation was successful. |
| 42 static bool SetupGalleryWatch( | 42 static bool SetupGalleryWatch( |
| 43 void* profile_id, | 43 void* profile_id, |
| 44 chrome::MediaGalleryPrefId gallery_id, | 44 MediaGalleryPrefId gallery_id, |
| 45 const base::FilePath& watch_path, | 45 const base::FilePath& watch_path, |
| 46 const std::string& extension_id, | 46 const std::string& extension_id, |
| 47 base::WeakPtr<MediaGalleriesPrivateEventRouter> event_router); | 47 base::WeakPtr<MediaGalleriesPrivateEventRouter> event_router); |
| 48 | 48 |
| 49 // Cancels the gallery watch for the extension specified by the | 49 // Cancels the gallery watch for the extension specified by the |
| 50 // |extension_id|. |profile_id| specifies the extension profile identifier. | 50 // |extension_id|. |profile_id| specifies the extension profile identifier. |
| 51 // |watch_path| specifies the absolute gallery path. | 51 // |watch_path| specifies the absolute gallery path. |
| 52 static void RemoveGalleryWatch(void* profile_id, | 52 static void RemoveGalleryWatch(void* profile_id, |
| 53 const base::FilePath& watch_path, | 53 const base::FilePath& watch_path, |
| 54 const std::string& extension_id); | 54 const std::string& extension_id); |
| 55 | 55 |
| 56 // Notifies about the extension unloaded/uninstalled event. | 56 // Notifies about the extension unloaded/uninstalled event. |
| 57 static void OnExtensionUnloaded(void* profile_id, | 57 static void OnExtensionUnloaded(void* profile_id, |
| 58 const std::string& extension_id); | 58 const std::string& extension_id); |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 class GalleryFilePathWatcher; | 61 class GalleryFilePathWatcher; |
| 62 typedef std::map<base::FilePath, GalleryFilePathWatcher*> WatcherMap; | 62 typedef std::map<base::FilePath, GalleryFilePathWatcher*> WatcherMap; |
| 63 | 63 |
| 64 // Use GetForProfile(). | 64 // Use GetForProfile(). |
| 65 GalleryWatchManager(); | 65 GalleryWatchManager(); |
| 66 ~GalleryWatchManager(); | 66 ~GalleryWatchManager(); |
| 67 | 67 |
| 68 // Initiates a gallery watch operation for the extension specified by | 68 // Initiates a gallery watch operation for the extension specified by |
| 69 // the |extension_id|. |gallery_id| specifies the gallery identifier and | 69 // the |extension_id|. |gallery_id| specifies the gallery identifier and |
| 70 // |watch_path| specifies the absolute path of the gallery. Returns true, | 70 // |watch_path| specifies the absolute path of the gallery. Returns true, |
| 71 // if the watch was set successfully. | 71 // if the watch was set successfully. |
| 72 bool StartGalleryWatch( | 72 bool StartGalleryWatch( |
| 73 chrome::MediaGalleryPrefId gallery_id, | 73 MediaGalleryPrefId gallery_id, |
| 74 const base::FilePath& watch_path, | 74 const base::FilePath& watch_path, |
| 75 const std::string& extension_id, | 75 const std::string& extension_id, |
| 76 base::WeakPtr<MediaGalleriesPrivateEventRouter> event_router); | 76 base::WeakPtr<MediaGalleriesPrivateEventRouter> event_router); |
| 77 | 77 |
| 78 // Cancels the gallery watch operation for the extension specified by the | 78 // Cancels the gallery watch operation for the extension specified by the |
| 79 // |extension_id|. |watch_path| specifies the absolute path of the gallery. | 79 // |extension_id|. |watch_path| specifies the absolute path of the gallery. |
| 80 void StopGalleryWatch(const base::FilePath& watch_path, | 80 void StopGalleryWatch(const base::FilePath& watch_path, |
| 81 const std::string& extension_id); | 81 const std::string& extension_id); |
| 82 | 82 |
| 83 // Handles the extension unloaded/uninstalled event. | 83 // Handles the extension unloaded/uninstalled event. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 94 // Key: Gallery watch path. | 94 // Key: Gallery watch path. |
| 95 // Value: GalleryFilePathWatcher*. | 95 // Value: GalleryFilePathWatcher*. |
| 96 WatcherMap gallery_watchers_; | 96 WatcherMap gallery_watchers_; |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(GalleryWatchManager); | 98 DISALLOW_COPY_AND_ASSIGN(GalleryWatchManager); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 } // namespace extensions | 101 } // namespace extensions |
| 102 | 102 |
| 103 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_M
ANAGER_H_ | 103 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_M
ANAGER_H_ |
| OLD | NEW |