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 class | |
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 | |
8 // future. Please refer to crbug.com/166950 for more details. | |
9 | |
10 #ifndef CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_MANA GER_H_ | |
11 #define CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_MANA GER_H_ | |
12 | |
13 #include <map> | |
14 #include <string> | |
15 | |
16 #include "base/file_path.h" | |
17 #include "base/memory/weak_ptr.h" | |
18 #include "chrome/browser/media_gallery/media_galleries_preferences.h" | |
19 | |
20 namespace extensions { | |
21 | |
22 class MediaGalleriesPrivateEventRouter; | |
23 | |
24 class GalleryWatchManager { | |
25 public: | |
26 // Returns the GalleryWatchManager for |profile_id|, creating it if it is not | |
27 // yet created. | |
28 static GalleryWatchManager* GetForProfile(void* profile_id); | |
29 | |
30 // Returns true if an GalleryWatchManager already exists for the specified | |
31 // |profile_id|. | |
32 static bool HasForProfile(void* profile_id); | |
33 | |
34 // Notifies about the profile shutdown event. | |
35 static void OnProfileShutdown(void* profile_id); | |
36 | |
37 // Initiates a gallery watch operation for the extension specified by | |
38 // the |extension_id|. |gallery_id| specifies the gallery identifier and | |
39 // |watch_path| specifies the absolute path of the gallery. Returns true, | |
40 // if the watch was set successfully. | |
41 bool StartGalleryWatch( | |
42 chrome::MediaGalleryPrefId gallery_id, | |
43 const FilePath& watch_path, | |
44 const std::string& extension_id, | |
45 base::WeakPtr<MediaGalleriesPrivateEventRouter> event_router); | |
46 | |
47 // Cancels the gallery watch operation for the extension specified by the | |
48 // |extension_id|. |watch_path| specifies the absolute path of the gallery. | |
49 void StopGalleryWatch(const FilePath& watch_path, | |
50 const std::string& extension_id); | |
51 | |
52 // Handles the extension unloaded/uninstalled/destroyed event. | |
53 void OnExtensionDestroyed(const std::string& extension_id); | |
54 | |
55 private: | |
56 class GalleryFilePathWatcher; | |
57 typedef std::map<FilePath, GalleryFilePathWatcher* > WatcherMap; | |
58 | |
59 // Use GetForProfile(). | |
60 explicit GalleryWatchManager(); | |
Lei Zhang
2013/01/04 22:56:28
nit: no need for explicit.
kmadhusu
2013/01/04 23:41:02
Done.
| |
61 ~GalleryWatchManager(); | |
62 | |
63 // Deletes the gallery watchers. | |
64 void DeleteAllWatchers(); | |
65 | |
66 // Removes the GalleryFilePathWatcher entry associated with the given | |
67 // |watch_path|. | |
68 void RemoveGalleryFilePathWatcherEntry(const FilePath& watch_path); | |
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 |