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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/media_galleries_private/gallery_watch_manager.h
diff --git a/chrome/browser/extensions/api/media_galleries_private/gallery_watch_manager.h b/chrome/browser/extensions/api/media_galleries_private/gallery_watch_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..cfbeb67586911b5b4af52871ce437b98dc27bd2a
--- /dev/null
+++ b/chrome/browser/extensions/api/media_galleries_private/gallery_watch_manager.h
@@ -0,0 +1,80 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Manages all the gallery file watchers for the associated profile. This
+// is temporary and will be moved to a permanent, public place in the near
+// future.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_MANAGER_H_
+#define CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_MANAGER_H_
+
+#include <map>
+#include <string>
+
+#include "base/file_path.h"
+#include "base/memory/ref_counted.h"
+#include "base/time.h"
+
+class Profile;
+
+namespace extensions {
+
+class GalleryFilePathWatcher;
+
+// 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
+// lives on the FILE thread.
+class GalleryWatchManager {
+ public:
+ // Returns the GalleryWatchManager for |profile|, creating it if it is not
+ // yet created.
+ static GalleryWatchManager* GetForProfile(const Profile* profile);
+
+ // Returns true if an GalleryWatchManager already exists for the specified
+ // |profile|.
+ static bool HasForProfile(const Profile* profile);
+
+ // Notifies about the |profile| shutdown event.
+ static void OnProfileShutdown(const Profile* profile);
+
+ ~GalleryWatchManager();
+
+ // Initiates a gallery watch operation for the extension specified by
+ // the |extension_id|. |gallery_id| specifies the gallery identifier and
+ // |watch_path| specifies the absolute path of the gallery. Returns true,
+ // if the watch was set successfully.
+ bool StartGalleryWatch(const std::string& gallery_id,
+ const FilePath& watch_path,
+ const std::string& extension_id);
+
+ // Cancels the gallery watch operation for the extension specified by the
+ // |extension_id|. |watch_path| specifies the gallery absolute path.
+ void StopGalleryWatch(const FilePath& watch_path,
+ const std::string& extension_id);
+
+ // Handles the extension unloaded/uninstalled/destroyed event.
+ 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
+
+ private:
+ typedef std::map<FilePath, scoped_refptr<GalleryFilePathWatcher> > WatcherMap;
+
+ // Use GetForProfile().
+ explicit GalleryWatchManager(const Profile* profile);
+
+ // Deletes the gallery watchers.
+ void DeleteAllWatchers();
+
+ // Current profile.
+ const Profile* profile_;
+
+ // Map to manage the gallery file path watchers.
+ // Key: Gallery watch path.
+ // Value: GalleryFilePathWatcher*.
+ WatcherMap gallery_watchers_;
+
+ DISALLOW_COPY_AND_ASSIGN(GalleryWatchManager);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698