Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Manages all the gallery file watchers for the associated profile. This | |
| 6 // is temporary and will be moved to a permanent, public place in the near | |
| 7 // future. | |
| 8 | |
| 9 #ifndef CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_MANA GER_H_ | |
| 10 #define CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_MANA GER_H_ | |
| 11 | |
| 12 #include <map> | |
| 13 #include <string> | |
| 14 | |
| 15 #include "base/file_path.h" | |
| 16 #include "base/memory/ref_counted.h" | |
| 17 #include "base/time.h" | |
| 18 | |
| 19 class Profile; | |
| 20 | |
| 21 namespace extensions { | |
| 22 | |
| 23 class GalleryFilePathWatcher; | |
| 24 | |
| 25 // The profile-keyed service that manages the gallery watchers. This class | |
|
Lei Zhang
2012/12/18 01:45:16
profile-keyed services inherit from ProfileKeyedSe
kmadhusu
2012/12/18 21:32:39
Removed the class header comments and added a coup
| |
| 26 // lives on the FILE thread. | |
| 27 class GalleryWatchManager { | |
| 28 public: | |
| 29 // Returns the GalleryWatchManager for |profile|, creating it if it is not | |
| 30 // yet created. | |
| 31 static GalleryWatchManager* GetForProfile(const Profile* profile); | |
| 32 | |
| 33 // Returns true if an GalleryWatchManager already exists for the specified | |
| 34 // |profile|. | |
| 35 static bool HasForProfile(const Profile* profile); | |
| 36 | |
| 37 // Notifies about the |profile| shutdown event. | |
| 38 static void OnProfileShutdown(const Profile* profile); | |
| 39 | |
| 40 ~GalleryWatchManager(); | |
| 41 | |
| 42 // Initiates a gallery watch operation for the extension specified by | |
| 43 // the |extension_id|. |gallery_id| specifies the gallery identifier and | |
| 44 // |watch_path| specifies the absolute path of the gallery. Returns true, | |
| 45 // if the watch was set successfully. | |
| 46 bool StartGalleryWatch(const std::string& gallery_id, | |
| 47 const FilePath& watch_path, | |
| 48 const std::string& extension_id); | |
| 49 | |
| 50 // Cancels the gallery watch operation for the extension specified by the | |
| 51 // |extension_id|. |watch_path| specifies the gallery absolute path. | |
| 52 void StopGalleryWatch(const FilePath& watch_path, | |
| 53 const std::string& extension_id); | |
| 54 | |
| 55 // Handles the extension unloaded/uninstalled/destroyed event. | |
| 56 void OnExtensionDestroyed(const std::string& extension_id); | |
|
Lei Zhang
2012/12/18 00:47:01
If you also make this a static function like OnPro
kmadhusu
2012/12/18 21:32:39
OnProfileShutdown() implementation modifies the gl
| |
| 57 | |
| 58 private: | |
| 59 typedef std::map<FilePath, scoped_refptr<GalleryFilePathWatcher> > WatcherMap; | |
| 60 | |
| 61 // Use GetForProfile(). | |
| 62 explicit GalleryWatchManager(const Profile* profile); | |
| 63 | |
| 64 // Deletes the gallery watchers. | |
| 65 void DeleteAllWatchers(); | |
| 66 | |
| 67 // Current profile. | |
| 68 const Profile* profile_; | |
| 69 | |
| 70 // Map to manage the gallery file path watchers. | |
| 71 // Key: Gallery watch path. | |
| 72 // Value: GalleryFilePathWatcher*. | |
| 73 WatcherMap gallery_watchers_; | |
| 74 | |
| 75 DISALLOW_COPY_AND_ASSIGN(GalleryWatchManager); | |
| 76 }; | |
| 77 | |
| 78 } // namespace extensions | |
| 79 | |
| 80 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_M ANAGER_H_ | |
| OLD | NEW |