Chromium Code Reviews| Index: chrome/browser/extensions/api/media_galleries_private/gallery_watch_manager_factory.h |
| diff --git a/chrome/browser/extensions/api/media_galleries_private/gallery_watch_manager_factory.h b/chrome/browser/extensions/api/media_galleries_private/gallery_watch_manager_factory.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9d61c9365082504e9a641881ccbac24f2d9b15ab |
| --- /dev/null |
| +++ b/chrome/browser/extensions/api/media_galleries_private/gallery_watch_manager_factory.h |
| @@ -0,0 +1,62 @@ |
| +// 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. |
| + |
| +#ifndef CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_MANAGER_FACTORY_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_MANAGER_FACTORY_H_ |
| + |
| +#include <map> |
| + |
| +#include "base/lazy_instance.h" |
| +#include "base/threading/thread_checker.h" |
| + |
| +class Profile; |
| + |
| +namespace extensions { |
| + |
| +class GalleryWatchManager; |
| + |
| +// Singleton that associate GalleryWatchManager objects with profiles. This |
| +// class is constructed, destructed and operated on the FILE thread. |
| +class GalleryWatchManagerFactory { |
|
Lei Zhang
2012/12/15 04:13:21
Can you just replace this with a map in gallery_wa
kmadhusu
2012/12/17 23:58:05
Done.
|
| + public: |
| + // Returns the GalleryFilePathWatchManagerFactory instance. |
| + static GalleryWatchManagerFactory* GetInstance(); |
| + |
| + // Returns true if an GalleryWatchManager already exists for the specified |
| + // |profile|. |
| + bool HasForProfile(const Profile* profile); |
| + |
| + // Returns the GalleryWatchManager for |profile|, creating it if it is not |
| + // yet created. |
| + GalleryWatchManager* GetForProfile(const Profile* profile); |
| + |
| + // Handles profile shutdown event. |
| + void OnProfileShutdown(const Profile* profile); |
| + |
| + private: |
| + friend struct base::DefaultLazyInstanceTraits<GalleryWatchManagerFactory>; |
| + |
| + typedef std::map<const Profile*, GalleryWatchManager*> WatchManagerMap; |
| + |
| + // Use GetInstance(). |
| + GalleryWatchManagerFactory(); |
| + |
| + // Leaky lazy instance. Destructor should not be called. |
| + virtual ~GalleryWatchManagerFactory(); |
| + |
| + // Map to keep track of profile specific GalleryWatchManager objects. |
| + // Key: Profile*. |
| + // Value: GalleryWatchManager*. |
| + // This map owns the GalleryWatchManager object. |
| + WatchManagerMap gallery_watch_managers_; |
| + |
| + // Make sure all the member functions are called on the right thread. |
| + base::ThreadChecker thread_checker_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(GalleryWatchManagerFactory); |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_GALLERY_WATCH_MANAGER_FACTORY_H_ |