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..ad93e63a8246f1d8422f7f625ef2dcee385dd64f |
--- /dev/null |
+++ b/chrome/browser/extensions/api/media_galleries_private/gallery_watch_manager.h |
@@ -0,0 +1,79 @@ |
+// 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 class |
+// lives on the file thread. This class is instantiated per profile. This |
+// is temporary and will be moved to a permanent, public place in the near |
Lei Zhang
2012/12/19 01:03:47
You should reference a bug for this.
kmadhusu
2012/12/19 21:55:55
Is it okay to specify the metabug crbug.com/144491
Lei Zhang
2012/12/19 22:35:50
Let's file a new bug. Otherwise, some people will
kmadhusu
2012/12/19 23:13:17
Done.
|
+// 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" |
Lei Zhang
2012/12/19 01:03:47
nit: move to .cc file
kmadhusu
2012/12/19 21:55:55
Done.
|
+ |
+class Profile; |
+ |
+namespace extensions { |
+ |
+class GalleryFilePathWatcher; |
Lei Zhang
2012/12/19 01:03:47
Why did this get moved out of GalleryWatchManager?
kmadhusu
2012/12/19 21:55:55
Fixed.
|
+ |
+class GalleryWatchManager { |
+ public: |
+ // Returns the GalleryWatchManager for |profile|, creating it if it is not |
+ // yet created. |
+ static GalleryWatchManager* GetForProfile(Profile* profile); |
+ |
+ // Returns true if an GalleryWatchManager already exists for the specified |
+ // |profile|. |
+ static bool HasForProfile(Profile* profile); |
+ |
+ // Notifies about the |profile| shutdown event. |
+ static void OnProfileShutdown(Profile* profile); |
+ |
+ ~GalleryWatchManager(); |
Lei Zhang
2012/12/19 01:03:47
private?
kmadhusu
2012/12/19 21:55:55
Done.
|
+ |
+ // 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(uint64 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. |
Lei Zhang
2012/12/19 01:03:47
nit: gallery absolute path -> absolute path of the
kmadhusu
2012/12/19 21:55:55
Done.
|
+ 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); |
+ |
+ private: |
+ typedef std::map<FilePath, scoped_refptr<GalleryFilePathWatcher> > WatcherMap; |
+ |
+ // Use GetForProfile(). |
+ explicit GalleryWatchManager(Profile* profile); |
+ |
+ // Deletes the gallery watchers. |
+ void DeleteAllWatchers(); |
+ |
+ // Current profile. |
+ 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_ |