Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: chrome/browser/extensions/api/media_galleries_private/gallery_watch_manager.h

Issue 11535008: Implement mediaGalleriesPrivate api to notify extensions about gallery changed events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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.
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 "chrome/browser/media_gallery/media_galleries_preferences.h"
18
19 class Profile;
20
21 namespace extensions {
22
23 class GalleryWatchManager {
24 public:
25 // Returns the GalleryWatchManager for |profile|, creating it if it is not
26 // yet created.
27 static GalleryWatchManager* GetForProfile(Profile* profile);
28
29 // Returns true if an GalleryWatchManager already exists for the specified
30 // |profile|.
31 static bool HasForProfile(Profile* profile);
32
33 // Notifies about the |profile| shutdown event.
34 static void OnProfileShutdown(Profile* profile);
35
36 // Initiates a gallery watch operation for the extension specified by
37 // the |extension_id|. |gallery_id| specifies the gallery identifier and
38 // |watch_path| specifies the absolute path of the gallery. Returns true,
39 // if the watch was set successfully.
40 bool StartGalleryWatch(chrome::MediaGalleryPrefId gallery_id,
41 const FilePath& watch_path,
42 const std::string& extension_id);
43
44 // Cancels the gallery watch operation for the extension specified by the
45 // |extension_id|. |watch_path| specifies the absolute path of the gallery.
46 void StopGalleryWatch(const FilePath& watch_path,
47 const std::string& extension_id);
48
49 // Handles the extension unloaded/uninstalled/destroyed event.
50 void OnExtensionDestroyed(const std::string& extension_id);
51
52 private:
53 class GalleryFilePathWatcher;
54 typedef std::map<FilePath, GalleryFilePathWatcher* > WatcherMap;
55
56 // Use GetForProfile().
57 explicit GalleryWatchManager(Profile* profile);
58 ~GalleryWatchManager();
59
60 // Deletes the gallery watchers.
61 void DeleteAllWatchers();
62
63 // Removes the GalleryFilePathWatcher entry associated with the given
64 // |watch_path|.
65 void RemoveGalleryFilePathWatcherEntry(const FilePath& watch_path);
66
67 // Current profile.
68 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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698